Repository navigation
fix(worktree): never rebase an already-pushed item branch; follow origin instead - #847
Conversation
…gin instead Once a branch is on origin its PR owns base drift (the supervisor merges the base in via GitHub's update-branch). Rebasing the local worktree then only makes the two histories diverge. Fetch the branch's own remote copy first: fast-forward when the remote moved (FollowedRemote), leave both-moved alone (Diverged), and rebase only a branch that was never pushed. Agentflare-Agent: claude-code Agentflare-Branch: task/331-rebase-item-worktree-rewrites-an-already Agentflare-Item: 331 Agentflare-Session: 10553a88-a912-4153-97c7-8d172ee44d92
|
Tracking this PR for automated review ( |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughThe worktree rebase path now checks the current branch on ChangesRemote branch following
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant rebase_item_worktree
participant follow_pushed_branch
participant origin
participant worktree
rebase_item_worktree->>follow_pushed_branch: Check current pushed branch
follow_pushed_branch->>origin: Fetch current branch
origin-->>follow_pushed_branch: Remote-tracking ref or fetch failure
alt Remote is ahead
follow_pushed_branch->>worktree: Fast-forward to remote tip
worktree-->>follow_pushed_branch: Fast-forward result
follow_pushed_branch-->>rebase_item_worktree: Return FollowedRemote
else Up to date or diverged
follow_pushed_branch-->>rebase_item_worktree: Return status without changing HEAD
else Remote state unavailable
follow_pushed_branch-->>rebase_item_worktree: Return no result
end
Merge Risk: ⚪ Minimal · up to No actionable issue remains from the reviewed change; it is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Fixes the merge-vs-rebase fight observed on PR #844 for item #331 .
What happened
Behindand ranpulls::update_branch; GitHub added aMerge branch 'master' into …commit to the remote branch.claimranrebase_item_worktree, which rebased the local worktree branch ontomasterwithout looking atorigin/<branch>.Fix
rebase_item_worktreenow fetches the worktree's own branch first. If it exists onorigin, the branch is followed, never rebased:git merge --ff-only origin/<branch>→ newRebaseOutcome::FollowedRemoteRebaseOutcome::Diverged, nothing touched (push_branch's integrate path handles it)UpToDate, no rebaseA branch that was never pushed rebases exactly as before (item remove engram #161's case).
push_branchlogs the two new outcomes; the MCP claim path already matched with_.Tests
New
crates/flare-git-core/src/worktree_rebase_tests.rs(worktree_tests.rs sits at the 1500-line gate): pushed branch follows the remote's merge with the original SHA kept as an ancestor; pushed branch untouched when only the target moved; diverged branch untouched; never-pushed branch still rebases.cargo nextest run -p flare-git-core255/255; clippy-D warningsclean onflare-git-coreandagentflare.Summary by CodeRabbit