submit: Check base CR status before submission#1154
Merged
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
This was referenced May 12, 2026
Before submitting, check whether any branch in the downstack has a base whose change has already been merged on the forge. If so, refuse to submit and instruct the user to run 'gs repo sync' first (or to bypass with --no-branch-check). This catches a class of confusion where an external merge (UI or auto-merge) has left local state and forge state in disagreement, and a subsequent submit would push to a base that no longer makes sense. Adds an optional-forge-repository DI binding so that submit commands that don't need a forge (e.g. --no-publish) don't trigger an eager remote-resolution prompt.
42f7928 to
0694ab5
Compare
Owner
|
Thanks, @ed-irl! |
Submit should reject stale downstack bases through one handler-level preflight instead of spreading the same forge validation through each submit command. This moves the check into the submit handler, where the complete submission scope is already known. Batch submit commands build one branch graph for their scoped branches, then pass that graph through the request so branch lookup and downstack walking reuse the same local topology. The handler collects the submitted branches and their downstacks, de-duplicates their forge change IDs, and fetches CR status in one batch before any submit work mutates state. The validation now belongs to submit-specific flow instead of the shared spice package. Branch and stack submit modes no longer have a separate `--no-branch-check` bypass; they use the existing `--force` escape hatch and tell callers to use it when the stale-base preflight blocks submission. Navigation comments still build their own graph after submitBranch updates local branch metadata, because their comments must reflect the post-submit change IDs and upstream branch names. Unit tests cover the handler preflight and graph reuse, and script tests cover stale-base rejection and `--force` bypasses across branch, stack, downstack, and upstack submit flows.
abhinav
added a commit
that referenced
this pull request
May 23, 2026
The branch merge command still expected stale-base validation to live behind its older command-local API, but PR #1154 moved that behavior into submit-specific preflight code. Extract stale-base detection into `spice.FindStaleBases` so submit and branch merge use the same graph and forge-state check. Branch merge now mirrors submit diagnostics while keeping its own `--no-branch-check` bypass wording. Refs #1154
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.
Adds a pre-submit check that walks the downstack of the branch being
submitted and queries the forge for the state of each base's change.
If a base branch's change has already been merged, submit is blocked
with a message pointing the user at
gs repo syncto recover.The check applies to
branch submit,stack submit,upstack submit,and
downstack submit. It is skipped when no supported forge isconfigured, or --force is used in cases where the user knows the local state
is intentionally divergent.
Summary
as it's required anyway for the other operations.
upstack submitto extract base-submitted check into ahelper for readability.
Test plan
Unit tests and test scripts verify behavior.