Skip to content

Commit e7acfc1

Browse files
skarimCopilot
andauthored
fix for rebase in sync cmd (#95)
* fix: sync performs cascade rebase even when trunk is already up-to-date Previously, `gh stack sync` gated the cascade rebase on whether trunk or stack branches were fast-forwarded during the current run. This meant that if the user had already updated trunk locally (e.g., `git pull`), sync would skip the rebase entirely even though stack branches hadn't been rebased onto the current trunk. This change: - Adds `stackNeedsRebase()` to detect stale branches regardless of whether trunk was updated in this run - Extracts shared helpers (`fastForwardTrunk`, `cascadeRebase`, `resolveOriginalRefs`) from duplicated code in sync.go and rebase.go into utils.go, reducing ~450 lines of duplication - Fixes rebase.go to skip queued branches (was only skipping merged), consistent with sync's behavior via `IsSkipped()` - Refactors rebase --continue to reuse the shared cascade helper Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address review feedback: error handling and index validation - resolveOriginalRefs now returns (map, error) instead of silently swallowing RevParseMap failures; sync warns and skips rebase, rebase aborts with a clear error - cascadeRebase uses a new Err field on the result struct to distinguish fatal errors (e.g. checkout failure) from recoverable conflicts; callers no longer enter conflict-recovery flow for non-conflict errors - continueRebase validates that remaining branch indices are contiguous in stack order, erroring out if the stack was reordered between conflict and --continue Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 54aa630 commit e7acfc1

5 files changed

Lines changed: 523 additions & 447 deletions

File tree

0 commit comments

Comments
 (0)