fix: support fork PRs by fetching via refs/pull/N/head#1219
Open
RobotSail wants to merge 1 commit intoanthropics:mainfrom
Open
fix: support fork PRs by fetching via refs/pull/N/head#1219RobotSail wants to merge 1 commit intoanthropics:mainfrom
RobotSail wants to merge 1 commit intoanthropics:mainfrom
Conversation
For cross-repository (fork) PRs, the head branch doesn't exist on the origin remote. The action previously tried `git fetch origin <branch>` which fails with "couldn't find remote ref". Now detects fork PRs via `isCrossRepository` from the GraphQL API and fetches using `pull/<number>/head:<branch>` refspec instead, which GitHub exposes for all PR heads regardless of source repo. Changes: - Add `isCrossRepository` to PR GraphQL query and type - Use `refs/pull/N/head` refspec for fork PRs in setupBranch() Fixes anthropics#1218
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fatal: couldn't find remote ref <branch>isCrossRepositoryfield to the PR GraphQL query and typepull/<number>/head:<branch>refspec instead of fetching by branch nameProblem
When
@claudeis tagged on a PR from a fork, the action runsgit fetch origin --depth=20 <branch-name>. Since the branch only exists on the fork's remote (not origin), this fails. GitHub exposes fork PR content atrefs/pull/<number>/head, which works regardless of source repo.Changes
src/github/api/queries/github.tsisCrossRepositoryto PR GraphQL querysrc/github/types.tsisCrossRepository: booleantoGitHubPullRequestsrc/github/operations/branch.tspull/N/headrefspec for fork PRs insetupBranch()test/data-formatter.test.tsisCrossRepositoryto test fixtureTest plan
bun run typecheckpassesbun test— 664 tests pass, 0 failuresFixes #1218
🤖 Generated with Claude Code