Repository navigation
Handle partial unstacking in sync and checkout - #576
Merged
skarim merged 1 commit intoOct 21, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking issues in the shared handling, command integration, or regression coverage; tests were not executed.
No open issues 🎉
What changed in this PR
Updates sync and checkout to handle partial unstacking safely while preserving local branch layout.
Changes:
- Shares keep-local handling across both commands, accepting merged-only remnants and retaining associations on blocked outcomes.
- Adds regression coverage for successful, partial, and failed unstacking.
- Updates prompts and documentation to avoid promising remote stack deletion.
| File | Description |
|---|---|
| README.md | Explains partial unstacking and recreation. |
| docs/src/content/docs/reference/cli.md | Updates sync conflict-resolution guidance. |
| docs/src/content/docs/guides/workflows.md | Documents keep-local behavior. |
| cmd/utils.go | Centralizes safe unstacking and lookup-error handling. |
| cmd/sync_test.go | Covers sync outcomes and verifies no pushing or recreation. |
| cmd/checkout.go | Uses shared handling and injectable selection. |
| cmd/checkout_test.go | Covers checkout outcomes and local-stack preservation. |
Review effort: Balanced
skarim
force-pushed
the
skarim/fix-keep-local-partial-merge
branch
from
October 21, 2026 19:35
50d4a66 to
14706fe
Compare
skarim
force-pushed
the
skarim/fix-keep-local-partial-merge
branch
from
October 21, 2026 19:48
14706fe to
620c787
Compare
Lukeghenco
approved these changes
Oct 21, 2026
1 task
doranoda
added a commit
to bex-co/bex
that referenced
this pull request
Nov 24, 2026
… pull request below it through GitHub's merge-async, as Devin's merge button does (w10/053)
A takeover session, or one given a number, asked to merge a person's
stacked pull request called PUT …/pulls/{n}/merge, which GitHub says "does
not support stacked pull requests or merging with a merge queue". Devin
Review: "merging a PR also merges every open PR below it in the stack",
and its button "shows exactly how many PRs the action will land".
- A pull request the merge-state read finds in a stack, merged without
auto or after GitHub refuses an auto arm because the stack is ready
now, goes to PUT …/pulls/{n}/merge-async: sha pinned, the stack base's
method rule, the commit text, merge_action default (GitHub merges
directly, or queues the stack where its base requires a merge queue),
never bypass_rules.
- A 202 is polled at GET …/merge-async/{uuid} once a second for at most
15 s (github.AsyncMergeWait), inside the :8091 listener's 30 s write
timeout; a failed read is retried until then. A 409 already pending at
the pinned head is waited for; at another head it is head_changed.
- merged answers merged with stack: true and records prState merged;
enqueued answers mergeQueue and records prMergeQueued; failed is
GitHub's words under merge_blocked, head_changed or
merge_method_not_allowed; still pending at the bound answers
mergePending: true and records nothing, and the driver's next says it
has not merged yet and to call the tool again to read the result.
- The state read adds stackEntry { position } and the stack's entries;
pullRequestCount is the pull request plus every open one below it, on
stack merges, queues and fresh stack arms.
- A pull request in no stack, an arm, a queued pull request and
disableAuto are unchanged.
ADR090 D3 (w10/053 amendment), ADR018, the agent-image README and the
backend AGENTS.md say so. Not walked live (no QA-owned stack fixture):
tested against the REST description's merge-async contract; the state
query ran read-only on github/gh-stack#576.
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.
Updates the "unstack on GitHub and keep local" choices in
gh stack syncandgh stack checkoutto handle merged PRs remaining in the old remote stack. Both paths preserve the local branch layout and only detach the remote association when recreation is safe.Functionality and user impact
submit; prompts now describe unstacking rather than guaranteed deletion.Key areas to review
cmd/utils.go:2160-2188:unstackAndKeepLocalcentralizes the outcome handling. Check the merged-only versus blocked-remnant distinction, the404/API-error paths, and that remote ID/number clearing and the catalog save happen only after a safe outcome.cmd/utils.go:2141-2158:resolveDivergenceDeleteRemotedistinguishes lookup failure from a missing stack and delegates to the shared helper. It keeps sync stopped and only offers recreation guidance after the local association is safely cleared.cmd/checkout.go:627-631:handleCompositionConflictuses the same helper for its keep-local choice, returning the existing local stack rather than importing or replacing its branches.Related issues
Stack created with GitHub Stacks CLI • Give Feedback 💬