feat(stack): properly update branches on stack reorder and add guards rebase in-progress

Description

glab stack reorder only rewrote the stack ref files and retargeted the MR base branches; it never rebased the underlying Git branches. So after moving a diff to a new position, the MRs pointed at the right bases but the commits stayed put: the first branch ended up containing every diff in the stack, and every MR was out of whack.

This MR makes reorder actually restack the branches. Because a reorder now rewrites Git history (and can hit conflicts partway through), a stack can be "mid-reorder" for the first time. This MR also adds a resumable flow and guards so that in-progress state can't corrupt the stack.

  • Rebase on reorder — each branch is rebased onto its new parent (rebase --onto) so local history matches the chosen order, then each MR is retargeted onto the branch now preceding it.
  • Conflicts handled during reorder — reorder progress is persisted to a state file. On a conflict the command explains how to resolve it, and glab stack reorder --continue / --abort finish or fully roll back the reorder (restoring original branch tips, ref files, and the original branch). reorder also refuses to start a second reorder while one is in progress.
  • Guards for in-progress state — a shared CheckNoRebaseInProgress helper blocks create, infer, save, amend, and sync while a reorder is paused or a Git rebase is active, with actionable error messages (Git alone doesn't reliably block these mid-rebase, e.g. commit --amend succeeds once the index is clean).
  • stack list reminder — warns (on stderr, so it stays out of piped output) that the listed order may be stale while a reorder is paused, without blocking the read-only command.

Resolves #8209

How has this been tested?

Unit tests were added covering the new behavior:

  • stack_reorder_test.go — the reorder rebase flow, --continue, --abort, and the already-in-progress guard.
  • stackutils_test.goCheckNoRebaseInProgress for both the paused-reorder and active-rebase cases.
  • stack_list_test.go — the paused-reorder reminder.
  • git_test.go / stacked_test.go — the reorder-state read/write helpers and ReorderInProgress / RebaseInProgress detection.

Additionally, tested manually through common use cases to ensure working as expected.

Screenshots (if appropriate):

Closes #8209

Disclaimer: I am not a Go dev by trade. Claude was used heavily to draft MR.

Merge request reports

Loading
Loading