-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fork with default branch only during pr create #12673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| "owner": {"login": "monalisa"} | ||
| }`)) | ||
| }`, func(payload map[string]interface{}) { | ||
| assert.Equal(t, true, payload["default_branch_only"]) |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.Equal(t, true, ...) is less idiomatic and typically produces less clear failure output than boolean-specific assertions. Prefer assert.True(t, payload["default_branch_only"].(bool)) (or a type-safe check plus assert.True) so failures are clearer and you also validate the expected type.
| assert.Equal(t, true, payload["default_branch_only"]) | |
| defaultBranchOnly, ok := payload["default_branch_only"].(bool) | |
| require.True(t, ok) | |
| assert.True(t, defaultBranchOnly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the type assertion makes it worse to read tbh
BagToad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
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.