Skip to content

Support modifying partially merged stacks - #575

Merged
skarim merged 3 commits into
skarim/fix-unstack-partial-mergefrom
skarim/fix-modify-partial-merge
Oct 21, 2026
Merged

skarim merged 3 commits into
skarim/fix-unstack-partial-mergefrom
skarim/fix-modify-partial-merge

Conversation

@skarim

@skarim skarim commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Allows gh stack submit to finish a modification when GitHub keeps merged PRs in the old stack. The local branch list is preserved, while the replacement stack contains only the remaining work.

Functionality and user impact

  • Accept a successful partial unstack when only merged PRs remain, and recognize an already-unstacked historical stack on retry. Unmerged PRs left remotely still block recreation, and API failures remain errors.
  • Keep modify recovery tied to the same local stack until submission and the catalog save finish. Retries no longer fork away from the pending modification; a single remaining active PR can complete without creating a stack.
  • Create replacement stacks without old merged PRs, while preserving merged members of an existing stack when updating or adopting it. Checkout uses the same membership rule to avoid false composition conflicts.

Key areas to review

  • cmd/submit.go:175-201 and cmd/submit.go:287-297: runSubmit handles pending modify recovery before considering an automatic fork. Completion counts active branches rather than historical entries, so one remaining PR can finish without a replacement stack.
  • cmd/submit.go:688-711 and cmd/submit.go:752-800: prepareStackRecreation recognizes merged-only remnants and records fresh merge state. handlePendingModify accepts those outcomes and persists the completed unstack step before clearing the local remote identity; the recovery record remains until submission finishes.
  • cmd/submit.go:851-864 / cmd/checkout.go:542-545: stackPRNumbers supplies the create/adopt/update membership rule, and stackCompositionMatches reuses it. Check that historical PRs are excluded without dropping merged members of the stack being reconciled.

Related issues


Stack created with GitHub Stacks CLI • Give Feedback 💬

Copilot AI balanced review requested due to automatic review settings October 21, 2026 18:59
@skarim
skarim added this pull request to stack #577 October 21, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Persistent recovery transitions need human validation, and a stale PR-state issue remains in partial-unstack retries.

1 open issue
What changed in this PR

Supports submitting modifications to partially merged stacks while preserving local branch history.

Changes:

  • Accept merged-only remote remnants during recovery.
  • Exclude historical merged PRs from replacement stacks.
  • Align checkout membership checks and expand regression coverage.
File Description
cmd/​submit.go Updates recovery, completion, and remote membership handling.
cmd/​submit_test.go Adds partial-unstack, retry, and membership tests.
cmd/​checkout.go Ignores historical merged nonmembers when comparing stacks.
cmd/​checkout_test.go Tests historical and current merged membership.

Review effort: Balanced

Comment thread cmd/submit.go
@skarim
skarim force-pushed the skarim/fix-modify-partial-merge branch from e07fe2d to 01c65b6 Compare October 21, 2026 19:48
@skarim
skarim merged commit 2d07a1c into main Oct 21, 2026
8 checks passed
@skarim
skarim deleted the skarim/fix-modify-partial-merge branch October 21, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants