Skip to content

revert: remove locally-merged pruning, require forge-confirmed merge#171

Merged
raphi011 merged 2 commits into
mainfrom
revert-local-merged
Apr 5, 2026
Merged

revert: remove locally-merged pruning, require forge-confirmed merge#171
raphi011 merged 2 commits into
mainfrom
revert-local-merged

Conversation

@raphi011

@raphi011 raphi011 commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Reverts the local branch ancestry check introduced in #169. The locally-merged detection using git branch --merged had a fundamental limitation: it doesn't work for squash-merges (the dominant workflow on GitHub). This caused false negatives where squash-merged branches wouldn't be auto-prunable, and false positives where local merges for other reasons (e.g. testing) could trigger unwanted pruning.

Pruning without --force now requires forge-confirmed PR merge status only. The --refresh-pr hint is surfaced in the error message.

Additional changes:

  • Open-PR worktrees are now protected from stale detection (isStaleWorktree returns false when PRState == open)
  • Refactors cd_cmd.go interactive/recent/target paths into runCdInteractive, runCdRecent, runCdTarget helpers
  • Refactors checkout_cmd.go interactive block into runCheckoutInteractive helper

Breaking Changes

  • None

Test Coverage

  • Unit tests added: 5 (4 for isStaleWorktree with PR states, 1 TestIsWorktreePrunable)
  • Integration tests added: 0

Reverts the local branch ancestry check introduced in #169. Pruning without
--force now requires forge-confirmed PR merge status only. Also adds open-PR
protection for stale detection, and refactors cd/checkout interactive flows
into helper functions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Apr 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 29.83871% with 87 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/wt/cd_cmd.go 25.00% 60 Missing and 3 partials ⚠️
cmd/wt/checkout_cmd.go 0.00% 24 Missing ⚠️

📢 Thoughts on this report? Let us know!

LocallyMerged was removed — git ancestry alone no longer grants force-free
pruning. Update tests to reflect that a git-merged branch without a PR cache
entry requires -f, and that all cache-absent branches appear in the error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@raphi011
raphi011 merged commit fe01a34 into main Apr 5, 2026
1 of 2 checks passed
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.

1 participant