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:
|
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.Tests
go test ./cmd/...TestApplyMustPushForSkippedAncestorsfor the ancestor propagation rule.E2E tests in this repo were not run here (environment uses default
mastertrunk; they expectmain).