Fork with default branch only during pr create#12673
Fork with default branch only during pr create#12673williammartin merged 2 commits intotrunkcli/cli:trunkfrom wm-explore-fork-branches-in-prcli/cli:wm-explore-fork-branches-in-prCopy head branch name to clipboard
Conversation
There was a problem hiding this comment.
Pull request overview
Updates gh pr create to request forks with default_branch_only=true, reducing fork size/time since the fork is only used to push the PR head branch.
Changes:
- Pass
default_branch_only=truewhen auto-forking duringpr create. - Update
pr createtests to assert the REST fork request payload includesdefault_branch_only.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/cmd/pr/create/create.go | Changes the fork API call to request default-branch-only forks. |
| pkg/cmd/pr/create/create_test.go | Adjusts the fork endpoint mock to validate default_branch_only in the request payload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BagToad
left a comment
There was a problem hiding this comment.
Approving since this LGTM, but I'll leave ya with a couple questions:
- Do you think we should document this in
gh pr create --help? Might be good. - Worst case - a user has a workflow that relies on getting all the branches, so we have a way for them to recover from this change? Can they run some git commands to fix their fork & workaround this behavior if they believe it to be undesirable?
Done.
(or whatever the remotes are actually called after this, but I assume that's what we do since that's the normal fork behaviour). |
Description
Fixes #12670
When
gh pr createauto-forks a repo, passdefault_branch_only=trueto the fork API.During
pr create, the fork exists solely as a place to push the PR head branch, so it's pretty unlikely that this will be a breaking change (but of course, not guaranteed). I think it's fine to make this change and then see if we have to do any apologies.Reviewer Notes
I haven't actually tried this out yet, juggling a few things, but I will ensure it has my eyes before merging.