fix(sync): Protect unsubmitted merged branches#1129
Merged
Conversation
Owner
Author
|
This change is part of the following stack: Change managed by git-spice. |
6d9a98d to
fa885cc
Compare
`repo sync` should not delete a branch just because its CR is merged. If the local branch has commits that were never part of the merged CR, removing it can discard work that has not reached the forge. This protects the case where the forge merged an older CR head, while the local branch moved on afterward. Use the forge-reported CR head as the deletion interlock. Merged branches are deleted automatically only when the local head is the same commit, or when local Git can prove that the forge head contains the local head. Otherwise sync keeps the branch in non-interactive mode and prompts before deletion when interaction is available. The compact forge status query now returns both state and head SHA, so the safety check reuses the existing status request without adding another network call. Resolves #1107
fa885cc to
9522445
Compare
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.
repo syncshould not delete a branch just because its CR is merged.If the local branch has commits that were never part of the merged CR,
removing it can discard work that has not reached the forge.
This protects the case where the forge merged an older CR head,
while the local branch moved on afterward.
Use the forge-reported CR head as the deletion interlock.
Merged branches are deleted automatically only when the local head is the
same commit,
or when local Git can prove that the forge head contains the local head.
Otherwise sync keeps the branch in non-interactive mode
and prompts before deletion when interaction is available.
The compact forge status query now returns both state and head SHA,
so the safety check reuses the existing status request without adding
another network call.
Test note:
The renamed-branch sync script now re-submits the branch after rename.
That keeps its original coverage focused on issue #401: deleting the
old tracking ref,
origin/feature1, when the local branch has beenrenamed to
feat1. Without re-submitting, the local branch contains anunsubmitted commit and correctly exercises the new #1107 skip path
instead of the renamed-tracking-ref deletion path.
Resolves #1107