Prefer upstream repo when creating fork PRs#2744
Conversation
- Treat `upstream` as the target repo when present - Add coverage for fork PR creation against an upstream base
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: 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. |
Summary
upstreamrepository as the PR base when bothoriginandupstreamremotes are available.origin.Testing
bun fmtbun lintbun typecheckNote
Medium Risk
Adjusts cross-repo PR detection to compare against
upstream(when present) instead of alwaysorigin, 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
originandupstreamremotes are configured, PR creation/lookup now treatsupstreamas the target/base repository (falling back tooriginwhenupstreamis missing) when determining whether a branch is cross-repo.Adds a regression test that simulates a forked
originbranch opening a PR against an upstream repo, assertinggh pr createuses 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.resolvePullRequestnow selects theupstreamremote as the target base repository when it is configured, falling back tooriginotherwise.isCrossRepositoryis computed by comparing the head remote against this resolved target rather than always againstorigin. A new test in GitManager.test.ts covers the case where bothoriginandupstreamremotes exist and verifies the PR is created with the fork head against the upstream base.Macroscope summarized 1b72627.