Skip to content

Sweep a Pruned Worktree Entry's Branch in the Same Run in pr_review.py - #3190

Merged
ptr727 merged 3 commits into
developfrom
feature/sweep-held-after-prune
Oct 17, 2026
Merged

ptr727 merged 3 commits into
developfrom
feature/sweep-held-after-prune

Conversation

@ptr727

@ptr727 ptr727 commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Summary

This fixes a finding raised on promotion #3189. cleanup --sweep read the branches held by worktrees before pruning the entries whose directory is gone. A finished branch held only by a pruned entry was therefore skipped by the loose-branch scan until the next run.

CleanupSweep.prune now returns the entries it pruned, or under a report the ones it would prune, and those entries no longer hold their branch. An entry kept as too recent, or still listed after a failed prune, keeps holding its branch.

Tests

  • test_a_pruned_entry_s_branch_is_swept_in_the_same_run and test_a_dry_run_reports_a_prunable_entry_s_branch both failed before the fix.
  • test_a_too_recent_prunable_entry_still_holds_its_branch fails when held drops every prunable entry.
  • The failed-prune test now carries a branch-holding entry. It fails when the failed path returns the entries anyway.
  • python3 -m unittest tests.test_pr_review ran 917+ tests, all OK.

Local review

Three recorded local-strict-review passes ran at the frontier tier. Both findings were test-coverage gaps, now closed. Nothing remains open.

🤖 Generated with Claude Code

ptr727 and others added 3 commits October 17, 2026 14:36
`cleanup --sweep` read the branches held by worktrees before pruning the
entries whose directory is gone, so a finished branch held only by a
pruned entry was skipped until the next run. `prune` now returns the
entries it removed, or under a report would remove, and those no longer
hold their branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 17, 2026 21:40
@ptr727

ptr727 commented Oct 17, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head a27f90986faf6e8ea871973d916edb01f8d6c174, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6cbc7a14-4519-4dd6-b3e9-0dd3796081fa
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cleanup-state and dry-run behavior warrant final human review.

No open issues 🎉

What changed in this PR

Updates cleanup sweeping so branches from pruned worktree entries are evaluated in the same run.

Changes:

  • Tracks pruned and report-prunable worktree entries.
  • Preserves branch holds for recent or failed prunes.
  • Adds regression coverage for apply, dry-run, recent, and failed-prune cases.
File Summary
tests/​test_pr_review.py Adds pruning and branch-sweep regression tests.
scripts/​pr_review.py Updates pruning and branch-hold tracking.

Review effort: Lite

@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.46%. Comparing base (3dcb1aa) to head (a27f909).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3190   +/-   ##
========================================
  Coverage    65.46%   65.46%           
========================================
  Files           17       17           
  Lines         9749     9750    +1     
========================================
+ Hits          6382     6383    +1     
  Misses        3367     3367           
Flag Coverage Δ
python-3.13 65.46% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit de75654 into develop Oct 17, 2026
14 checks passed
@ptr727
ptr727 deleted the feature/sweep-held-after-prune branch October 17, 2026 21:53
ptr727 added a commit that referenced this pull request Oct 17, 2026
- #3186 adds the local half of post-merge cleanup to `pr_review.py
cleanup`. With `--checkout <base-clone>`, it removes the merged branch's
worktrees and local branch after the remote delete and fast-forwards the
base clone's `develop`. `cleanup --sweep` reports, and with `--apply`
removes, the worktrees and branches an interrupted or abandoned session
left behind.
- #3188 points every skill that finishes a worktree at those commands,
in place of the raw `git worktree remove`, `git branch -D`, and remote
delete, which the host-safety allowlist does not cover. The skills are
`repo-worktree`, `drive-pr`, `merge-and-release`, `backlog-burndown`,
`pr-review-conduct`, `unattended-handoff`, `resync-a-repo`, and
`audit-a-repo`. `git-commit-conventions`'s post-squash `-D` exception
now admits a tip behind the verified head.

- #3190 fixes a promotion-review finding. `cleanup --sweep` now judges a
branch held only by a pruned worktree entry in the same run, rather than
skipping it until the next.
- #3191 fixes a second promotion-review finding. `unattended-handoff`
step 7 no longer claims that no worktree outlives the lane, and it names
a cleanup that could not run or that failed.

Installed Skills change at release.

Closes #3184
Closes #1682
Closes #1693

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants