gh-stack icon indicating copy to clipboard operation
gh-stack copied to clipboard

gh stack merge: add --admin to bypass unmet rules (bypass_rules)

Open cbcoutinho opened this issue 3 days ago • 0 comments

Problem

Admins have no way to merge a stack whose requirements aren't met:

  • gh pr merge <n> --admin is refused for a stacked PR: "This pull request is part of a stack and must be merged using the asynchronous merge REST API."
  • gh stack merge has no bypass option, and its help says bypassing isn't supported.

But the async merge API already accepts bypass_rules. In a repo whose default branch has a ruleset requiring one approving review, with an admin whose ruleset bypass mode is pull_request:

Request Result
PUT …/pulls/N/merge-async {merge_method, merge_action} failed: "At least 1 approving review is required by reviewers with write access." (response echoes bypass_rules: false)
the same, plus bypass_rules: true merged

Proposed fix (implemented, ready to PR)

Branch: https://github.com/cbcoutinho/gh-stack/tree/merge-admin-flag (compare with main)

I couldn't open the PR myself: the repo doesn't allow pull requests from my account (CreatePullRequest permission error). A maintainer is welcome to open it from the branch, or to enable outside PRs and I'll open it.

  • gh stack merge --admin sends bypass_rules: true, in both the headless (--yes / non-TTY) path and the interactive wizard, and prints a warning before merging. GitHub still decides whether the viewer may bypass.
  • bypass_rules is omitted from the request body unless --admin is set, so existing requests are unchanged.
  • --admin is refused (exit 5) when the base branch uses a merge queue. I couldn't confirm how the server handles a bypass together with an enqueue, so this fails closed instead of guessing.
  • ClientOps.MergeStackAsync takes a new bypassRules bool parameter (interface, client, mock, callers).
  • Docs: CLI reference, README, agent skill reference, workflows guide, FAQ, overview and Merge API reference (bypass_rules documented). The web-UI note in guides/ui.md is unchanged.
  • Tests cover the request body, both merge paths and the merge-queue refusal. go vet ./... and go run ./scripts/test -workers 4 pass locally.

bypass_rules isn't in the public Merge API docs yet, so please check that it's the intended contract.


This issue was generated with the help of AI, and reviewed by a Human

cbcoutinho avatar Nov 28 '26 17:11 cbcoutinho