pr create: Fix remote resolution with `--fill` and `--base` by 9999years · Pull Request #14196 · cli/cli · GitHub
Skip to content

pr create: Fix remote resolution with --fill and --base - #14196

Draft
9999years wants to merge 1 commit into
cli:trunkfrom
9999years:wiggles/xuzt
Draft

9999years wants to merge 1 commit into
cli:trunkfrom
9999years:wiggles/xuzt

Conversation

@9999years

Copy link
Copy Markdown

NB: This is AI generated and although I've tested it manually, I haven't read the code; it's not ready for review or submission yet.

pr create --fill assumed that the selected PR repository remote also contained the local tracking ref for --base. When that ref existed only on another remote, the generated Git log range referenced a nonexistent ref and failed before the PR could be created.

Owner-qualified bases had two related problems. The owner leaked into the Git revision, producing refs such as upstream/MyOrg:branch, and the owner was discarded when constructing the PR target. As a result, --web still opened the compare page for the default repository instead of the repository selected by OWNER:branch.

Build an ordered list of base tracking refs, starting with the default PR remote and falling back to other matching remotes when the Git log fails. For OWNER:branch, resolve the remote by owner and host, use its repository as the PR base for both API and web flows, and use the unqualified branch name for the Git comparison and GitHub request. This also supports forks whose repository name differs from the upstream repository. Preserve the original Git error when no candidate succeeds.

Add regression coverage for unqualified remote fallback and an exact owner-qualified --web --fill flow.

`pr create --fill` assumed that the selected PR repository remote also
contained the local tracking ref for `--base`. When that ref existed only
on another remote, the generated Git log range referenced a nonexistent ref
and failed before the PR could be created.

Owner-qualified bases had two related problems. The owner leaked into the
Git revision, producing refs such as `upstream/MyOrg:branch`, and the owner
was discarded when constructing the PR target. As a result, `--web` still
opened the compare page for the default repository instead of the repository
selected by `OWNER:branch`.

Build an ordered list of base tracking refs, starting with the default PR
remote and falling back to other matching remotes when the Git log fails.
For `OWNER:branch`, resolve the remote by owner and host, use its repository
as the PR base for both API and web flows, and use the unqualified branch
name for the Git comparison and GitHub request. This also supports forks
whose repository name differs from the upstream repository. Preserve the
original Git error when no candidate succeeds.

Add regression coverage for unqualified remote fallback and an exact
owner-qualified `--web --fill` flow.
Copilot AI balanced review requested due to automatic review settings August 19, 2026 00:42
@9999years
9999years requested a review from a team as a code owner August 19, 2026 00:42
@9999years
9999years requested a review from BagToad August 19, 2026 00:42
@9999years
9999years marked this pull request as draft August 19, 2026 00:42
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed unmet-requirements and removed needs-triage needs to be reviewed labels Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves pr create base resolution for --fill and owner-qualified bases.

Changes:

  • Retries Git log using matching remotes.
  • Resolves OWNER:branch to its target repository.
  • Adds regression tests for fallback and web flows.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pkg/cmd/pr/create/create.go Implements base repository and tracking-ref resolution.
pkg/cmd/pr/create/create_test.go Tests remote fallback and qualified web creation.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

return nil, "", nil, err
}
}
return resolvedBaseRepo, branch, trackingBranches, nil
}
resolvedBaseRepo := baseRepo
if !ghrepo.IsSame(baseRemote, baseRepo) {
resolvedBaseRepo, err = api.GitHubRepo(client, baseRemote)
}
}

resolveBase := func(base string) (*api.Repository, string, []string, error) {
Comment on lines +781 to +787

This branch has not been deployed

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

Labels

external pull request originating outside of the CLI core team unmet-requirements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants