Skip to content

submit: Check base CR status before submission#1154

Merged
abhinav merged 3 commits into
mainfrom
submit-stale-base-check
May 17, 2026
Merged

submit: Check base CR status before submission#1154
abhinav merged 3 commits into
mainfrom
submit-stale-base-check

Conversation

@ed-irl

@ed-irl ed-irl commented May 12, 2026

Copy link
Copy Markdown
Collaborator

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 sync to recover.

The check applies to branch submit, stack submit, upstack submit,
and downstack submit. It is skipped when no supported forge is
configured, or --force is used in cases where the user knows the local state
is intentionally divergent.

Summary

  • Add the check in the submit handler for single branch and batch submissions.
  • For batch submissions, load the branch graph in advance and re-use it,
    as it's required anyway for the other operations.
  • Refactor upstack submit to extract base-submitted check into a
    helper for readability.

Test plan

Unit tests and test scripts verify behavior.

@ed-irl

ed-irl commented May 12, 2026

Copy link
Copy Markdown
Collaborator Author

@ed-irl ed-irl changed the title submit: validate downstack against forge before submit ci: add merge-guard command and branch merge May 12, 2026
@ed-irl ed-irl added the skip changelog PRs that don't need a changelog. label May 12, 2026
@ed-irl ed-irl requested a review from abhinav May 12, 2026 14:04
@ed-irl ed-irl removed the skip changelog PRs that don't need a changelog. label 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.
@ed-irl ed-irl force-pushed the submit-stale-base-check branch from 42f7928 to 0694ab5 Compare May 12, 2026 14:10
@ed-irl ed-irl changed the title ci: add merge-guard command and branch merge Check branch status before submission May 12, 2026
@abhinav

abhinav commented May 13, 2026

Copy link
Copy Markdown
Owner

Thanks, @ed-irl!
I'll try to give this stack time over this week/weekend.

abhinav added 2 commits May 17, 2026 14:29
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 abhinav changed the title Check branch status before submission submit: Check base CR status before submission May 17, 2026
@abhinav abhinav enabled auto-merge (squash) May 17, 2026 21:37
@abhinav abhinav merged commit 7fbfdaf into main May 17, 2026
22 checks passed
@abhinav abhinav deleted the submit-stale-base-check branch May 17, 2026 21:40
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants