Skip to content

Conversation

@williammartin
Copy link
Member

@williammartin williammartin commented Feb 12, 2026

Description

Fixes #12670

When gh pr create auto-forks a repo, pass default_branch_only=true to 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.

@williammartin williammartin marked this pull request as ready for review February 12, 2026 16:46
@williammartin williammartin requested a review from a team as a code owner February 12, 2026 16:46
Copy link
Contributor

Copilot AI left a 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=true when auto-forking during pr create.
  • Update pr create tests to assert the REST fork request payload includes default_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"])
Copy link

Copilot AI Feb 12, 2026

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.

Suggested change
assert.Equal(t, true, payload["default_branch_only"])
defaultBranchOnly, ok := payload["default_branch_only"].(bool)
require.True(t, ok)
assert.True(t, defaultBranchOnly)

Copilot uses AI. Check for mistakes.
Copy link
Member

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

Copy link
Member

@BagToad BagToad left a 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh pr create: support default-branch-only when prompting to fork

2 participants