Skip to content

fix(prune): OR over local + upstream in step prune integration check - #2515

Merged
max-sixty merged 2 commits into
mainfrom
step-prune-or-targets
May 1, 2026
Merged

max-sixty merged 2 commits into
mainfrom
step-prune-or-targets

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

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 — the same diverged-case false negative #2513 fixed for wt list and #2507 fixed for wt remove / wt merge.

This change passes the local default branch directly to integration_reason, letting it OR over local + upstream internally like wt remove and wt merge already do. The actual deletion gate inside prepare_worktree_removal was already correct, so this just stops the outer filter from silently dropping legitimately-integrated candidates.

effective_integration_target, integration_target, and their RepoCache fields are now dead and deleted.

Test plan

  • New regression test_prune_locally_merged_when_upstream_diverged (mirrors test_remove_merged_locally_when_upstream_diverged). Verified to fail on the pre-fix code path with No merged worktrees to remove, passes on the fix.
  • Symmetric test_prune_squash_merged_on_remote_when_local_diverged covers the merged-on-remote direction; pins forward-compatibility.
  • cargo run -- hook pre-merge --yes — 3411/3411 pass, no snapshots to review.

max-sixty and others added 2 commits April 30, 2026 19:48
`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>
@max-sixty
max-sixty merged commit d66faea into main May 1, 2026
28 checks passed
@max-sixty
max-sixty deleted the step-prune-or-targets branch May 1, 2026 02:58
@max-sixty max-sixty mentioned this pull request May 3, 2026
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>
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