fix: handle fork PRs by fetching via refs/pull/N/head#963
Open
stakeswky wants to merge 1 commit intoanthropics:mainfrom
Open
fix: handle fork PRs by fetching via refs/pull/N/head#963stakeswky wants to merge 1 commit intoanthropics:mainfrom
stakeswky wants to merge 1 commit intoanthropics:mainfrom
Conversation
When a PR originates from a fork, `git fetch origin <branch>` fails because the branch only exists on the fork's remote. Fix: detect cross-repository PRs via the `isCrossRepository` GraphQL field and fetch using `pull/<number>/head:<branch>` refspec instead, which is the standard GitHub mechanism for accessing fork PR branches. Changes: - Add `isCrossRepository` and `headRepository` to PR GraphQL query - Add corresponding fields to GitHubPullRequest type - Branch checkout uses pull ref for fork PRs - Update test fixtures with new fields
|
Please merge this. The claude GH action is pretty much useless for external contributions without this. |
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
Fixes #962.
When
claude-code-actionis triggered via@claudeon a pull request from a fork, the action fails with:This happens because
git fetch origin <branch>is used, but the branch only exists on the fork's remote.Fix
Detect cross-repository PRs using the
isCrossRepositoryGraphQL field and fetch viapull/<number>/head:<branch>refspec — the standard GitHub mechanism for accessing fork PR branches.Changes
isCrossRepositoryandheadRepositoryfields toPR_QUERYGitHubPullRequestpull/N/headrefspec for fork PRs, keeping the existingfetch origin <branch>path for same-repo PRsTesting