Repository navigation
Don't fail inter-branch merge when existing PR can't be fast-forwarded - #17091
Merged
Merged
Conversation
The inter-branch merge workflow does a non-force push to update an existing merge/<from>-to-<to> PR. When that PR branch has diverged (manual conflict-resolution commits, or a regenerated ResetToTargetPaths commit), the push is rejected as non-fast-forward. The rejection was caught but git's exit code (1) leaked through as the process exit code, so the job failed red -- creating notification noise and a red actions dashboard even though nothing was actually wrong. Now the existing-PR update path distinguishes a benign non-fast-forward rejection (leave the PR untouched, succeed) from a genuine push failure (auth/network/permissions), which still throws and fails the job. The fast-forward update behavior is preserved for repos that rely on it. Fixes #16606 Co-authored-by: Copilot <[email protected]> Copilot-Session: db9119eb-05f0-44f4-a5ca-ffc406876b29
Closed
2 tasks
Member
Author
|
@lbussell per our conversation earlier today. Proposed fix to swallow the error when the branch can't be fast forwarded so we stop getting red actions and notifications of failing builds. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the inter-branch merge workflow script to avoid failing the workflow job when updating an existing merge/<from>-to-<to> PR branch cannot be fast-forwarded, while still failing on genuine git push errors (auth/network/permissions).
Changes:
- Reworks the “existing PR update” branch push to capture
git pushoutput/exit code and explicitly classify non-fast-forward rejection as a benign condition. - Resets
LASTEXITCODEto prevent a benign non-fast-forward rejection from leaking as the overall PowerShell process exit code. - Tightens failure handling by throwing on non-benign push failures instead of blanket-catching and warning.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
akoeplinger
approved these changes
Jul 14, 2026
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
The inter-branch merge workflow (
inter-branch-merge.ps1) updates an existingmerge/<from>-to-<to>PR with a plain (non-force)git push. When that PR branch has diverged from the freshly generated merge branch, the push is rejected as non-fast-forward. This happens routinely when:ResetToTargetPathsis configured (e.g. dotnet/sdk, dotnet/macios), which adds a fresh reset commit on every run, so the remote branch tip is no longer an ancestor.The rejection was already caught, but git's exit code (
1) leaked through as the process exit code (there is no later native command under-QuietComments, and noexit 0), so the job failed red. Result: notification noise and a sea of red on the dotnet/sdk actions dashboard even though nothing was actually wrong.There is no "neutral" conclusion available for a normal workflow job (that only exists via the Checks API for GitHub Apps), so the fix makes the benign case report success.
Fix
In the existing-PR update path only:
[rejected]/non-fast-forward/fetch first/tip of your current branch is behind). The existing PR is left untouched and the job succeeds.LASTEXITCODEis reset so the rejection no longer leaks as the process exit code.throws instead of being silently caught. Previously the blanketcatchalso hid auth/network/permission errors — so this is actually stricter than before.All earlier steps (
fetch/checkout/reset/ResetToTargetPaths/PR lookup) are untouched and still fail normally. The non-PR path (force-push + create PR) and comment behavior are unchanged.Validation
Parser::ParseFile— no parse errors.git pushexits 1 → classified benign →LASTEXITCODEreset to 0 → shell exits 0. A fast-forwardable push still takes the success branch; non-matching errors fall through tothrow.Fixes #16606