Skip to content

feat: record stacked base locally so gw status suggests -B - #45

Merged
zawakin merged 1 commit into
mainfrom
feature/gwbase-local-record
Jun 29, 2026
Merged

feat: record stacked base locally so gw status suggests -B#45
zawakin merged 1 commit into
mainfrom
feature/gwbase-local-record

Conversation

@zawakin

@zawakin zawakin commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

Phase 2 of stacked-PR support. gw new --stack now records the parent in branch.<child>.gwBase (local git config). Before a PR exists, gw status reads it and turns the create-PR next-action into gh pr create -B <parent>, eliminating the one manual step that survived #43's structural redesign — forgetting -B.

Once a PR exists, GitHub's base_branch stays authoritative (unchanged); gwBase only fills the pre-PR gap.

Changes

  • git: branch_base / set_branch_base / unset_branch_base helpers (local config, no network).
  • new: record the base after a successful --stack.
  • next_action: CreatePr { base: Option<String> } — emits -B <parent> when stacked.
  • status: read + filter the recorded base (real parent, not the default branch / self), show Base: <parent> (stacked, PR not created yet) pre-PR, pass it to detect.
  • sync: unset_branch_base after restacking onto the default branch (no longer stacked). Branch deletion drops the whole [branch] section, so cleanup needs no change (verified).

Rationale for the stale-base decision

A gwBase can go stale only in a narrow window (parent merged + branch deleted between --stack and the child's PR). Phase 2 deliberately does not verify the parent's remote existence:

  • gh pr create -B X fails loudly on a missing base (gw never runs it itself — it's a suggested command).
  • Verification would add an ls-remote round-trip to every gw status on a stacked branch.
  • The correct response to "parent merged" is sync/rebase, which the parent/child guard work (a later phase) will own holistically — dropping -B here would be half-right and mask it.

Test

  • next_action: unit test for CreatePr { base: Some(..) }.
  • tests/new_test.rs: --stack records gwBase; plain new records none; gw status surfaces the stacked base and the -B feature/parent hint end-to-end (no manual checking needed).
  • mise run verify passes.

🤖 Generated with Claude Code

gw new --stack now records the parent in branch.<child>.gwBase. Before a PR
exists, gw status reads it and turns the create-PR next-action into
`gh pr create -B <parent>`, so the stacked base can't be forgotten -- the one
manual step that survived the structural redesign. Once a PR exists, GitHub's
base stays authoritative; gwBase only fills the pre-PR gap.

- git: branch_base / set_branch_base / unset_branch_base helpers (local config)
- new: record the base after a successful --stack
- next_action: CreatePr carries an optional stacked base
- status: read + filter the recorded base, show it pre-PR, pass it to detect
- sync: unset on restack (branch is no longer stacked); branch delete clears
  the rest, so cleanup needs no change

Stale gwBase (parent merged before the child PR is opened) is left for the
parent/child guard work; gh pr create errors loudly on a missing base.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zawakin zawakin self-assigned this Jun 29, 2026
@zawakin
zawakin merged commit ee643c0 into main Jun 29, 2026
7 checks passed
@zawakin
zawakin deleted the feature/gwbase-local-record branch June 29, 2026 11:44
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