fix(cmd): only push stack branches when submit will touch PRs#89
fix(cmd): only push stack branches when submit will touch PRs#89
Conversation
Submit used to force-push every stack branch before the PR phase, so branches were published even when the user skipped opening a PR. Plan each branch first (GitHub adopt check, prompts, --update-only), then push only branches that will get PR work or must exist on the remote as a base for a descendant PR. PR execution reuses the plan. Add a unit test for ancestor push propagation on skip. Co-authored-by: christopher.hiller <christopher.hiller@consensys.net>
|
Claude finished @boneskull's task in 2m 52s —— View job Code Review
The core idea—plan PR actions first, then selectively push—is sound and cleanly solves the original issue (branches landing on origin when the user ESCs the title prompt). The refactor is well-structured and the logic is correct. A few things worth addressing: Moderate: GitHub client created twice
// doSubmitPushAndPR could pass the client:
return executePRDecisions(g, cfg, root, decisions, ghClient, dryRun, openWeb, s)Minor: O(n²) linear scan in push loop
Minor:
|
Merge main's CascadeOptions/SubmitOptions refactor into the selective push flow. Reuse a single GitHub client from planning through executePRDecisions, use a branch->decision map for pushes, and only set pushAnyway on skipped ancestors. Remove duplicate doSubmitPRs/createPRForBranch path; keep prContext and executePRCreate for the execution phase. Expand applyMustPushForSkippedAncestors tests (update/adopt child, 3-level chain, non-skip ancestor). Co-authored-by: christopher.hiller <christopher.hiller@consensys.net>
Closes #79.
Summary
gh stack submitpreviously force-pushed every branch in scope before the PR phase, so a branch could land onorigineven when the user skipped creating a PR (e.g. ESC on the title prompt).What changed
--push-only), we now resolve the PR action up front—existing PR update, adopt from GitHub, new PR after prompt, or skip (--update-only/ user skip).pushAnyway) so GitHub has a valid base ref.executePRDecisionsruns the API work from the precomputed plan; new PRs useexecutePRCreatewith the already-chosen title/body.--update-onlydry-run still prints skip lines for branches without PRs.Merged with
mainafter #88 (SubmitOptions,CascadeOptions,prContext).doSubmitPushAndPRtakesSubmitOptions;continuepasses the same struct.Review follow-ups (from #89 (comment))
NewClientwhen not dry-run and not--push-only; passed through toexecutePRDecisions(no second client in the PR phase).decisionByNamemap instead of scanningdecisionsper branch.prActionSkip(matches the field comment; harmless before but clearer).Tests
go test ./cmd/...TestApplyMustPushForSkippedAncestorsextended: childprActionUpdate/prActionAdopt, three-level chain, non-skip ancestor unchanged.E2E tests in this repo were not run here (environment may use default
mastertrunk while tests expectmain).