Repository navigation
fix(prune): OR over local + upstream in step prune integration check - #2515
Merged
Merged
Conversation
`wt step prune` was the lone remaining caller of `Repository::effective_integration_target` — a "pick one ref" helper whose own docstring warned it was unsafe for safety-critical checks. In the diverged case it returned `origin/main`, then handed it to `integration_reason`, which couldn't resolve an upstream of an already-remote ref and ended up checking only that single side. Branches merged into local `main` while `origin/main` had unique commits never got pruned — same diverged-case false negative `wt list` (#2513) and `wt remove` (#2507) fixed. Pass the local default branch directly so `integration_reason` ORs over local + upstream internally, matching `wt remove` / `wt merge`. The actual deletion gate inside `prepare_worktree_removal` was already correct, so this just stops the outer filter from silently dropping legitimately-integrated candidates. Deletes `effective_integration_target`, `integration_target`, and their RepoCache fields (zero remaining callers). Adds two regression tests mirroring the `remove.rs` patterns; the locally-merged variant is verified to fail on the pre-fix code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
worktrunk-bot
approved these changes
May 1, 2026
Merged
max-sixty
added a commit
that referenced
this pull request
May 3, 2026
Cuts v0.47.0. Highlights: - **Integration detection fix** across `wt list`, `wt remove`, `wt merge`, `wt step prune` for the local/upstream-diverged case (#2507, #2513, #2515). - **Faster shell-command dispatch** (~10ms per invocation, 1.49× on trivial aliases) via event-driven signal forwarding (#2537, #2538), plus parallel config load (#2543) and merged cold-start prewarm rev-parse (#2541). - **`wt switch <number>` suggests `pr:N` / `mr:N`** instead of just `--create` (#2516). - **Library API breaking changes**: `RefSnapshot` cutover (#2528, #2530) and the `for-each` direct-exec change (#2465). Full list in `CHANGELOG.md`. See `CHANGELOG.md` for the complete entry. > _This was written by Claude Code on behalf of @max-sixty_ --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wt step prunewas the lone remaining caller ofRepository::effective_integration_target— a "pick one ref" helper whose own docstring warned it was unsafe for safety-critical checks. In the diverged case it returnedorigin/main, then handed it tointegration_reason, which couldn't resolve an upstream of an already-remote ref and ended up checking only that single side. Branches merged into localmainwhileorigin/mainhad unique commits never got pruned — the same diverged-case false negative #2513 fixed forwt listand #2507 fixed forwt remove/wt merge.This change passes the local default branch directly to
integration_reason, letting it OR over local + upstream internally likewt removeandwt mergealready do. The actual deletion gate insideprepare_worktree_removalwas already correct, so this just stops the outer filter from silently dropping legitimately-integrated candidates.effective_integration_target,integration_target, and theirRepoCachefields are now dead and deleted.Test plan
test_prune_locally_merged_when_upstream_diverged(mirrorstest_remove_merged_locally_when_upstream_diverged). Verified to fail on the pre-fix code path withNo merged worktrees to remove, passes on the fix.test_prune_squash_merged_on_remote_when_local_divergedcovers the merged-on-remote direction; pins forward-compatibility.cargo run -- hook pre-merge --yes— 3411/3411 pass, no snapshots to review.