feat: guard stale stacked base at PR-creation time (Phase 4-A) - #48
Merged
Conversation
When a stacked branch's recorded base (gw new --stack) merged before the branch got its own PR, gw status used to suggest `gh pr create -B <parent>`, which fails because the parent branch is gone. Now status checks the recorded base's PR pre-PR; if it merged, the next action becomes "rebase onto main and open a normal PR" via the new NextAction::StackedBaseMerged. This closes the stale-gwBase case that Phase 2 explicitly deferred here. Also fold NextAction::detect's growing positional args into a DetectContext struct (removing the too_many_arguments allow); named fields keep call sites legible and let new signals be added without churn. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The StackedBaseMerged hint suggested `git rebase origin/main`, which on a stacked branch re-applies the (squash-)merged base's commits too — a doubled, conflict-prone diff. Use `git rebase --onto origin/main <base>` so only this branch's own commits are replayed. If the base ref is gone it now fails loudly instead of silently double-applying (a fuller fix — keeping the base alive and a recorded-SHA fallback — follows). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 29, 2026
zawakin
added a commit
that referenced
this pull request
Jun 29, 2026
Reflect the stacked-PR work (#48-#51) in the skill's stacking section: gw sync restacks with rebase --onto (replaying only the child's commits, not the merged parent's), gw status guides the pre-PR case, and gw cleanup keeps a base branch alive while an open child PR still targets it. Adds a note on why --onto is required after a squash merge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Phase 4-A of stacked-PR support: handle the stale stacked base case that #45 explicitly deferred.
When a stacked branch's recorded base (
gw new --stack→branch.<child>.gwBase) merges before the child gets its own PR,gw statuspreviously suggestedgh pr create -B <parent>— which fails, because the parent branch no longer exists. Now:gw statuschecks the recorded base's PR state before the child PR exists.NextAction::StackedBaseMerged, instead of the stale-B <parent>hint.Also
Fold
NextAction::detect's positional argument list into aDetectContextstruct (removes the#[allow(clippy::too_many_arguments)]from #45). Named fields keep the call sites legible and let new signals be added without churning every caller — which is exactly what this PR needed.Test
next_action: unit testtest_recorded_base_merged_before_pr_suggests_rebase(and the whole detect suite migrated to theDetectContextbuilder).mise run verifypasses.Scope
Phase 4-B (cleanup refusing to delete a branch that open child PRs still target) is a separate PR.
🤖 Generated with Claude Code