Skip to content

Handle partial unstacking in sync and checkout - #576

Merged
skarim merged 1 commit into
skarim/fix-modify-partial-mergefrom
skarim/fix-keep-local-partial-merge
Oct 21, 2026
Merged

skarim merged 1 commit into
skarim/fix-modify-partial-mergefrom
skarim/fix-keep-local-partial-merge

Conversation

@skarim

@skarim skarim commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Updates the "unstack on GitHub and keep local" choices in gh stack sync and gh stack checkout to 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

  • Use the same unstack-and-keep-local handling in both commands. Accept merged-only remnants and report retained history rather than claiming the remote stack was deleted.
  • Keep the local association when unmerged PRs still prevent recreation or the API fails. A failed stack lookup no longer masquerades as an already-deleted stack.
  • Preserve local branches and stack order. Sync stops before pushing or recreating anything and directs users to submit; prompts now describe unstacking rather than guaranteed deletion.

Key areas to review

  • cmd/utils.go:2160-2188: unstackAndKeepLocal centralizes the outcome handling. Check the merged-only versus blocked-remnant distinction, the 404/API-error paths, and that remote ID/number clearing and the catalog save happen only after a safe outcome.
  • cmd/utils.go:2141-2158: resolveDivergenceDeleteRemote distinguishes 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: handleCompositionConflict uses 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 💬

@skarim
skarim added this pull request to stack #577 October 21, 2026 18:59
Copilot AI balanced review requested due to automatic review settings 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.

🟢 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
skarim force-pushed the skarim/fix-keep-local-partial-merge branch from 50d4a66 to 14706fe Compare October 21, 2026 19:35
@skarim
skarim force-pushed the skarim/fix-keep-local-partial-merge branch from 14706fe to 620c787 Compare October 21, 2026 19:48
@skarim
skarim merged commit 282dffa into main Oct 21, 2026
8 checks passed
@skarim
skarim deleted the skarim/fix-keep-local-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