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:
|
|
Claude finished @cursor[bot]'s task in 2m 30s —— View job Code Review
All four issues raised in the previous review have been addressed. Here's the follow-up assessment: Previous issues — resolvedDouble GitHub client creation — Fixed. O(n²) push loop scan — Fixed.
Missing test cases — All four gaps are closed: New minor issue: unused
|
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>
f46d84b to
247463a
Compare
|
I'll analyze this and get back to you. |
|
Claude finished @boneskull's task in 2m 48s —— View job Code Review
All issues raised in the two previous reviews have been addressed. Here's the current-state assessment: Previous issues — all resolvedDouble GitHub client — Fixed. O(n²) push loop — Fixed.
Missing test cases — All four gaps closed: Unused New observation: duplicate skip-message code
// dry-run path (line 451):
if d.skipReason == "update-only" {
fmt.Printf("Skipping %s %s\n", s.Branch(b.Name), s.Muted("(no existing PR, --update-only)"))
}
continue
// non-dry-run path (line 457):
case "update-only":
fmt.Printf("Skipping %s %s\n", s.Branch(b.Name), s.Muted("(no existing PR, --update-only)"))The dry-run What's good
|

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