feat: add 'gs ci merge-guard' to block out-of-order stacked PR merges#1153
Open
ed-irl wants to merge 4 commits into
Open
feat: add 'gs ci merge-guard' to block out-of-order stacked PR merges#1153ed-irl wants to merge 4 commits into
ed-irl wants to merge 4 commits into
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
This was referenced May 12, 2026
2488f59 to
6391910
Compare
1b2630b to
b25aab5
Compare
Owner
|
@ed-irl is this intended as a guard in the merge command? |
362ddaf to
f282a95
Compare
73e4a70 to
992b28b
Compare
Introduces restack.Options{AutoResolve} and threads an opts *Options
parameter through the high-level restack entry points (RestackBranch,
RestackStack, RestackDownstack) and the merge/sync RestackHandler
interfaces, with all current callers passing nil.
This is foundational plumbing for the restack auto-resolve feature.
Landing it on a branch below the consuming stacks lets every branch
inherit the 3-arg signature, rather than the signature change living
on a branch parallel to its callers.
Add 'gs ci merge-guard' command that checks whether a PR is safe to merge by verifying its base branch is trunk. Trunk is detected from a new metadata marker embedded in navigation comments. - Embed trunk metadata in nav comments (<!-- gs:trunk <name> -->) - Export NavCommentRegexes and ExtractTrunkFromComment from submit - Add --trunk override and --all flag for unmanaged PRs - Wire forge.Repository as Kong singleton provider
Collaborator
Author
|
@abhinav no, this is meant to be run in a Github action. This prevents people from hitting the "merge" button in github (or advises against it via a failed check anyways) if the target branch isn't the repo main branch. |
Owner
|
Okay, I can see the argument for guarding against human error with an optional CI integration. |
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
gs ci merge-guard <number>command for forge CI/CD pipelines that fails when a change request's base branch is not trunk, preventing out-of-order merges in a stacked PR workflow.merge-guard command
gs ci merge-guard <number>resolves the change, detects its trunk, and exits non-zero if the base branch is not trunk. Trunk is detected from the git-spice navigation comment on the PR, or overridden with--trunk. Unmanaged PRs (no navigation comment) are allowed through by default;--allblocks any PR whose base is not trunk. The newcicommand group is registered under aCIgroup in the CLI.Trunk metadata in navigation comments
To support detection, the navigation comment now embeds the trunk branch name via a trunk marker (
<!-- gs:trunk main -->, or the Markdown link form for forges that use it).generateStackNavigationCommentandupdateNavigationCommentstake the trunk name, threaded through fromh.Store.Trunk()in the submit handler.ExtractTrunkFromCommentparses either marker form back out, and the previously unexported_navCommentRegexesis exported asNavCommentRegexesso merge-guard can reuse it to find navigation comments.Tests
Unit tests cover
ExtractTrunkFromComment(HTML, Markdown, missing, and full-comment round-trip) and the updated nav-comment generation. Script tests cover merge-guard for safe, blocked, deep-stack,--trunkoverride, unmanaged/--all, already-merged, closed, and not-found cases. Existing nav-comment golden files are updated to include the trunk marker.