Skip to content

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

Backlog

Description

@cbcoutinho

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions