Merge Stacked PRs with merge command#307
Draft
skarim wants to merge 6 commits into
Draft
Conversation
skarim
force-pushed
the
skarim/merge-cmd
branch
2 times, most recently
from
July 25, 2026 17:06
a14ba2a to
c8efa62
Compare
skarim
force-pushed
the
skarim/docs-content-updates
branch
from
July 25, 2026 17:06
379fd43 to
ace18c0
Compare
skarim
force-pushed
the
skarim/merge-cmd
branch
2 times, most recently
from
July 26, 2026 00:33
d69a1b4 to
0ff36e1
Compare
skarim
force-pushed
the
skarim/docs-content-updates
branch
from
July 26, 2026 13:41
bdc11e1 to
094328f
Compare
Follow-up polish for `gh stack merge` (the command itself landed in the
previous commit). These changes refine the interactive wizard, enrich the
PR picker, and replace the merge client's bespoke HTTP handling with the
standard go-gh REST client.
Wizard and stepper:
- Redesign the top stepper as a segmented bar: completed steps are green,
the active step is the brightest, and upcoming steps are dimmed. Steps
are separated by a Powerline arrow that blends into the shading, with a
graceful fallback to abutting segments on terminals that lack the glyph
(e.g. Apple Terminal). Set GH_STACK_POWERLINE=1/0 to override detection.
- Show the stack number in the header ("Merge stack #123").
- Hide the header and stepper once the merge is submitted so the live
progress view stands on its own.
PR picker:
- Render each pull request on two lines: the title (white/black, a touch
bolder when selected) above its "#number • branch" (gray, fainter when
deselected). Titles are fetched in one batched GraphQL query (PRTitles)
and fall back to the branch name.
- Scroll long stacks in a fixed 10-item window with persistent "N more"
indicators, so the list no longer jumps as those hints appear and
disappear. Add shift+up / shift+down to jump to the top or bottom.
Progress and outcome:
- Always render a status line ("Submitting merge request...") so it does
not pop in later and shift the view, and normalize messages to end in an
ellipsis.
- Print the final result from the command layer rather than the TUI: a
success line that includes the merge commit SHA
("Merged #1, #2 into main (abc1234)"), an atomic-rollback note on
failure, a distinct message when the user stops watching an in-flight
merge, and "Cancelled operation, nothing merged" on cancel.
- Clamp every rendered line to the terminal width so resizing no longer
leaves duplicated header lines behind, and make truncation ANSI-aware.
Async-merge client:
- Use the go-gh REST client (c.rest.Put / c.rest.Get) for both the submit
and poll endpoints, removing the bespoke http.Client, base-URL helper,
and manual response decoding. The REST client discards non-2xx bodies,
but that only costs the rare 400 message and 409 UUID: real merge
failures still surface through the 200 poll body, and the in-range PRs
are validated open, non-draft, and non-merged before submitting.
- Add classifyAsyncMergeError to map status codes to clear errors (404
unavailable, 409 already exists, 400 no longer mergeable) and drop the
now-unused AsyncMergeResult.StatusCode field. Rework the client tests to
drive the REST client through a stub http.RoundTripper.
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.
This adds a new
gh stack mergecommand built on GitHub's new async merge API, which can land multiple stacked PRs atomically. It merges some or all of a stack in one atomic operation: every PR up to and including the one you choose is merged into the base branch, and if any PR can't be merged, none are.What's new
--yesor no TTY, the whole stack (or everything up to the given PR) merges without prompting, using your last-used merge method unless one is given via--merge/--squash/--rebase/--merge-method.gh pr merge— the stack merge lands directly, not through a queue. Admin bypass is likewise not applied by the stack-merge API.Changes
The command
cmd/merge.go— the newgh stack mergecommand: resolves the target stack (current branch / stack number / PR number), computes the mergeable candidates (open, non-draft, contiguous from the bottom), and runs either the interactive wizard or the headless submit-and-poll path. Registered incmd/root.go.GitHub client
internal/github/merge_async.go— an async stack-merge client over the REST API:MergeStackAsync(submit) andGetAsyncMergeResult(poll) on go-gh's REST client, returning astatusenum (pending/merged/failed); plusRepoMergeConfig(allowed methods and last-used default, via GraphQL),BaseBranchPolicy(merge-queue detection), andPRTitles(batch PR titles for the picker). Added toClientOpsandMockClient.Wizard TUI
internal/tui/mergeview/(new package) — the Bubble Tea wizard: a stepper banner, the bottom-anchored PR picker with a scrolling viewport, the allowed-method picker, the confirm step, and the live progress view.Docs
README.md,docs/CLI reference and workflows guide,skills/gh-stack/SKILL.md, andAGENTS.md— document the command, its targeting and merge-method behavior, and the merge-queue limitation.Testing
cmd/merge_test.go), the async-merge client includingstatusdecoding and error mapping (internal/github/merge_async_test.go), and the wizard model (internal/tui/mergeview/model_test.go).go test -race -count=1 ./...andgo vet ./...are clean, and the changed files passgofmt.Stack created with GitHub Stacks CLI • Give Feedback 💬