abhinav / abhinav/git-spice

CI guard to block out-of-order stacked PR merges

Open
#1,242 0 comments 0 reactions 0 assignees View on GitHub
enhancement proposal/pending
Dominant language
Go
Stars
762
Forks
72
Avg merge
18h 24m
Merged PRs (30d)
28

Description

## Problem

Nothing stops a stacked PR from being merged before its downstack
dependencies have landed. Merging mid-stack out of order corrupts the
stack: the merged PR pulls in commits from branches below it that were
never reviewed or merged on their own, and the remaining PRs retarget
against an unexpected base.

## Proposal

Add `gs ci merge-guard `, a CI/CD subcommand intended to run in
forge pipelines. It fails when a PR's base branch is not trunk, i.e.
when the PR still has unmerged downstack dependencies.

Behavior:

- By default only git-spice managed PRs are checked; unmanaged PRs pass
through. `--all` blocks any PR whose base is not trunk.
- Trunk is auto-detected from a `gs:trunk` metadata marker embedded in
the navigation comment, so the command needs no local state and can
run against any PR number in CI. `--trunk` overrides detection.
- Exits 0 when safe to merge, non-zero with a descriptive error
otherwise.

Note: the trunk marker overloads the navigation comment to carry
metadata, which is more load-bearing than before — open to alternative
mechanisms for tracking trunk across forges.

## Tracked by

- #1153 — `gs ci merge-guard` command

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.