fix: handle fork PRs by fetching via refs/pull/N/head (#962) (#963)

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

Co-authored-by: User <user@example.com>
This commit is contained in:
不做了睡大觉
2026-04-14 20:33:04 -07:00
committed by GitHub
co-authored by User
parent 3943183052
commit c3bf66dbc2
7 changed files with 39 additions and 3 deletions
+7
View File
@@ -57,6 +57,13 @@ export type GitHubPullRequest = {
baseRefName: string;
headRefName: string;
headRefOid: string;
isCrossRepository: boolean;
headRepository: {
owner: {
login: string;
};
name: string;
} | null;
createdAt: string;
updatedAt?: string;
lastEditedAt?: string;