Skip to content

fix for rebase in sync cmd#95

Draft
skarim wants to merge 1 commit into
mainfrom
skarim/sync-rebase
Draft

fix for rebase in sync cmd#95
skarim wants to merge 1 commit into
mainfrom
skarim/sync-rebase

Conversation

@skarim
Copy link
Copy Markdown
Collaborator

@skarim skarim commented May 17, 2026

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


Stack created with GitHub Stacks CLIGive Feedback 💬

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>
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.

1 participant