Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The history-rewriting and recovery changes have unresolved safety issues that require fixes and final human validation.
7 open issues
Persist rebase cutoff before initial sync journal save · New Verify merged PR covers boundary and target ancestry · New Resolve cutoff against planned fast-forward tip · New Check ancestry independently of bottom-branch cutoff · New Recover fork boundary from old trunk reflog · New Reject stale local base when resolving rebase boundary · New Normalize remote-qualified trunk during comparison · New
What changed in this PR
Adds base-retarget handling to gh stack, allowing existing stacks to follow GitHub’s new base without recreating their pull requests.
Changes:
- Adds retarget detection, history repair, and
--accept-base-changeconsent to sync and rebase. - Records the accepted target for rebase continuation and abort recovery.
- Guards publishing against stale bases and reports pending repairs in view and checkout.
| File | Description |
|---|---|
| docs/src/content/docs/reference/cli.md | Documents retarget behavior and consent flags. |
| cmd/view.go | Reports retargets and marks JSON repair status. |
| cmd/view_test.go | Tests pending-repair reporting without trunk changes. |
| cmd/utils.go | Adds shared detection, publishing guards, and cutoff selection. |
| cmd/sync.go | Integrates retarget repair into synchronization. |
| cmd/sync_test.go | Tests repair, repeat runs, and conflict rollback. |
| cmd/submit.go | Blocks submission against a stale base. |
| cmd/submit_test.go | Tests retarget and lookup-failure guards. |
| cmd/rebase.go | Adds consent flags and target journaling. |
| cmd/rebase_worktree.go | Handles target publication and original-trunk restoration. |
| cmd/rebase_test.go | Tests retarget history, consent, and recovery. |
| cmd/push.go | Blocks pushing against a stale base. |
| cmd/push_test.go | Tests the retarget publishing guard. |
| cmd/checkout.go | Uses the server base and warns about pending repairs. |
| cmd/checkout_test.go | Tests tracked-stack warnings and import-base selection. |
Review effort: Max
A merged branch below a retargeted stack can land in the old base after that base merged. Check the boundary the cascade drops, and skip the prompt only when those commits reached the new base.
Importing onto GitHub's new base hid the pending retarget, so the next rebase skipped consent. Keep the merged first PR's base so sync repairs the stack, and compare GitHub's base only for the tracked-stack warning.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds CLI support for base changes GitHub makes automatically when a stack's base branch is deleted.
syncandrebaserepair local history against the new server base without recreating the stack or its PRs.Functionality and user impact
syncandrebaseuse GitHub's new base and the existing validated--ontocascade to replay the stack's own commits. The local trunk changes only after rebasing succeeds; continuation keeps the accepted target, and abort restores the old trunk.--accept-base-change.pushandsubmitdirect users to sync before publishing a retargeted stack.viewreports the new server base and marks the bottom branch'sneedsRebasein JSON without changing the saved local trunk. Remote checkout warns when an existing local stack still needs repair, and imports keep the merged first PR's old base so the next sync repairs the stack with the same consent checks.Key areas to review
cmd/utils.go: shared single-stack base lookup, publishing guard, and consent/cutoff selection. Only a detected retarget switches the bottom branch to--onto; ordinary trunk rebases retain their existing behavior.cmd/rebase.goandcmd/sync.go: target resolution, selected-range handling, and passing the cutoff into the existing rebase flow.cmd/rebase_worktree.go:TargetTrunkis journaled separately from the applied trunk. Check completion/save retries and abort restoration, covered by the retarget recovery cases incmd/rebase_test.go.cmd/push.go,cmd/submit.go,cmd/view.go, andcmd/checkout.go: publishing guards and pending-repair reporting without implicit history rewrites. Arbitrary retargeting and branching-stack workflows remain out of scope.