Detect pull requests against upstream repositories - #3907
Conversation
|
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 Plus 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 introduces a new feature for detecting pull requests against upstream repositories in fork workflows, with significant changes to PR detection, creation, and listing logic across multiple layers. Multiple unresolved review comments identify potential edge case bugs with org-owned forks and GitHub Enterprise hosts. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e512ba2d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5df12cd1e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b16508f364
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b16508f to
2d23111
Compare
There was a problem hiding this comment.
Effect service conventions: two new Effect.catchTag usages were introduced. The convention is to use Effect.catchTags({ ... }) even when handling a single tag.
Posted via Macroscope — Effect Service Conventions
- Detect upstream and fork repository context - Use the GitHub API for cross-repository pull requests - Preserve standard creation for same-repository pull requests
41b6411 to
5b173be
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6f34800. Configure here.

Summary
upstreamGitHub remoteowner:branchand target GitHub CLI operations at the upstream repositoryupstreamfrom overriding a valid GitHuboriginRoot cause
PR discovery derived the fork-qualified head selector, but GitHub CLI still resolved the repository from the local checkout's
origin. In a fork checkout, that queried the fork rather than the upstream repository where the pull request exists.Impact
Branches pushed to a fork now show their upstream pull request metadata in T3 Code. Related PR operations consistently use the upstream repository context.
Validation
vp checkvp run typecheckNote
Medium Risk
Changes core PR lookup and creation paths for forks, including a new REST API create path that may behave differently from
gh pr createfor permissions or edge cases.Overview
Fixes PR discovery in fork checkouts where GitHub CLI still scoped to origin, so open PRs against the parent repo were missed.
Provider selection prefers a conventional GitHub fork layout: when
originandupstreamshare the same repo name on the same host but different owners, registry resolution and branch head context treat upstream as the PR target. Unrelatedupstreamremotes no longer override a valid GitHuborigin.GitHub CLI gains optional
--repoon list/view/checkout/default-branch, resolves base vs head repo context (including viagh repo viewparent metadata), usesgh pr viewfor qualifiedowner:branchselectors instead ofgh pr list --head, and creates fork → upstream PRs throughgh apiwhile same-repo PRs still usegh pr create.GitManager passes fork source metadata on create, uses
targetRemoteNamefor merge-base range resolution, and improves remote URL parsing (HTTPS trailing slashes, GitHub Enterprise host in coordinates).Reviewed by Cursor Bugbot for commit 13d7bdf. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Detect pull requests against upstream repositories for conventional GitHub forks
upstreamis a conventional fork oforigin(same host and repo name, different owner), the provider context now prefers the upstream remote, scoping PR listings, creation, checkout, and default branch queries to the upstream repository.listOpenPullRequestsdetects qualifiedowner:branchhead selectors and callsgh pr viewdirectly instead ofgh pr list, reducing API calls for cross-repo lookups.createPullRequestresolves base and head repository context viagh repo viewand usesgh api POST /repos/{base}/pullswhen targeting a different repository (e.g. an org-owned fork), falling back togh pr createfor same-repo PRs.parseGitHubRepositoryNameWithOwnerFromRemoteUrlnow handles SCP-style remotes and non-github.com hosts, returninghost/owner/namecoordinates for GHE instances.upstreamremote will now have PR operations (list, create, checkout, default branch) scoped to the upstream repository rather than origin.Macroscope summarized 13d7bdf.