Conversation
Documents the approved design for automatically pushing branches to remote before creating or updating PRs. This removes manual push friction from the stacked PR workflow.
Stack
Managed by gh-stack |
There was a problem hiding this comment.
Pull request overview
This PR adds a design document describing how gh stack pr should automatically push the current branch (with --force-with-lease and upstream tracking) before creating or updating a pull request.
Changes:
- Introduces an auto-push flow for
gh stack pr, including a newPushWithUpstreamhelper ininternal/git/git.go. - Specifies when and how the push should be invoked in
cmd/pr.goprior to PR creation/update. - Documents expected error-handling behavior and test strategy (unit and manual) for the new behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Insert push call in `runPR()` after validating the branch is tracked (after line ~56), before checking if PR exists: | ||
|
|
||
| ```go | ||
| // Push branch to remote (with tracking) before PR operation | ||
| fmt.Printf("Pushing %s to origin...\n", branch) | ||
| if err := g.PushWithUpstream(branch); err != nil { | ||
| return fmt.Errorf("failed to push branch: %w", err) | ||
| } |
There was a problem hiding this comment.
Here the design says to insert the push call after validating that the branch is tracked, but the "Error Handling" section below describes the first push for an untracked branch succeeding because -u sets up tracking. These two statements conflict: if tracking validation still happens before PushWithUpstream, the first-push scenario would fail instead of succeeding, so either the validation step or the described behavior should be updated for consistency.
| | Scenario | Behavior | | ||
| |----------|----------| | ||
| | No network | Command fails with git's error message | | ||
| | Diverged history (remote has unseen commits) | Force-with-lease rejects push, command fails | | ||
| | No permission | Command fails with git's error message | | ||
| | Branch already up-to-date | Push succeeds quickly, continues to PR | | ||
| | First push (no tracking) | `-u` sets up tracking, succeeds | |
There was a problem hiding this comment.
The Markdown table in this section starts each row with a double pipe (||), which introduces an extra empty column and is likely to render incorrectly. This should be a standard two-column table with a single leading pipe so that "Scenario" and "Behavior" are the only columns.
No description provided.