feat(vcs): auto-rebase and retry a push when the remote moved ahead - #62
Merged
Conversation
pushCurrentBranch failed hard on a non-fast-forward rejection, leaving the user to fetch/rebase/push by hand. Now, when a push is rejected only because the remote branch has commits the local branch doesn't, the driver fetches that remote branch, rebases the local commits onto it, and retries the push once. A rebase that hits conflicts is aborted so the working tree is never left mid-rebase, and the conflict is surfaced with actionable detail. Auth/branch-protection failures still fail fast. Applies to all remote-targeted push paths (existing upstream, new upstream, and explicit remote). Co-Authored-By: Claude Opus 4.8 <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.
Problem
When pushing, if the remote branch had commits the local branch didn't,
GitVcsDriver.pushCurrentBranchfailed hard with "The remote branch has commits this branch doesn't. Pull or rebase onto the remote branch, then push again." — leaving the user to fetch, rebase, and push by hand every time.Fix
The push now self-heals the common non-fast-forward case. When a push is rejected only because the remote moved ahead, the driver:
git fetch <remote> <branch>).git rebase FETCH_HEAD).Safety:
git rebase --abort) so the working tree is never left mid-rebase, and the conflict is surfaced with an actionable message.workflowscope, and branch-protection rejections still fail fast, unchanged.Applies to all remote-targeted push paths: existing upstream, new upstream (
-u), and explicitremoteName.Tests
Added two integration tests in
GitVcsDriverCore.test.ts(real git, real temp remotes):All 56 tests in the file pass.
🤖 Generated with Claude Code