Skip to content

Prefer upstream repo when creating fork PRs#2744

Closed
felixfong227 wants to merge 1 commit into
pingdotgg:mainfrom
felixfong227:feature/fork-pr-upstream
Closed

Prefer upstream repo when creating fork PRs#2744
felixfong227 wants to merge 1 commit into
pingdotgg:mainfrom
felixfong227:feature/fork-pr-upstream

Conversation

@felixfong227
Copy link
Copy Markdown

@felixfong227 felixfong227 commented May 17, 2026

Summary

  • Prefer the upstream repository as the PR base when both origin and upstream remotes are available.
  • Keep fork PR detection aligned with the repository that will actually receive the PR, instead of always comparing against origin.
  • Add a regression test covering a fork branch that should open a PR against the upstream repo with the correct owner-qualified head reference.

Testing

  • Added a GitManager test for creating a fork PR against an upstream base repo.
  • Not run: bun fmt
  • Not run: bun lint
  • Not run: bun typecheck

Note

Medium Risk
Adjusts cross-repo PR detection to compare against upstream (when present) instead of always origin, which can change which head selectors are probed and where PRs are created. Risk is moderate because it affects PR creation/lookup logic across different remote configurations.

Overview
When both origin and upstream remotes are configured, PR creation/lookup now treats upstream as the target/base repository (falling back to origin when upstream is missing) when determining whether a branch is cross-repo.

Adds a regression test that simulates a forked origin branch opening a PR against an upstream repo, asserting gh pr create uses the owner-qualified head selector (e.g. owner:branch) and the upstream base branch.

Reviewed by Cursor Bugbot for commit 1b72627. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Prefer upstream remote over origin when resolving base repository for fork PRs

When creating a PR, makeGitManager.resolvePullRequest now selects the upstream remote as the target base repository when it is configured, falling back to origin otherwise. isCrossRepository is computed by comparing the head remote against this resolved target rather than always against origin. A new test in GitManager.test.ts covers the case where both origin and upstream remotes exist and verifies the PR is created with the fork head against the upstream base.

Macroscope summarized 1b72627.

- Treat `upstream` as the target repo when present
- Add coverage for fork PR creation against an upstream base
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9c8399e8-d0b0-486a-a6fd-5a5379fb88ff

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels May 17, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 17, 2026

Approvability

Verdict: Needs human review

This PR changes runtime behavior in how PRs are targeted when working with forks - PRs will now be created against the upstream repository instead of origin. While the change is small and well-tested, it modifies core PR creation logic and warrants human review.

You can customize Macroscope's approvability policy. Learn more.

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant