mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-03 17:58:30 +08:00
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>
124 lines
2.0 KiB
TypeScript
124 lines
2.0 KiB
TypeScript
// Types for GitHub GraphQL query responses
|
|
export type GitHubAuthor = {
|
|
login: string;
|
|
name?: string;
|
|
};
|
|
|
|
export type GitHubComment = {
|
|
id: string;
|
|
databaseId: string;
|
|
body: string;
|
|
author: GitHubAuthor;
|
|
createdAt: string;
|
|
updatedAt?: string;
|
|
lastEditedAt?: string;
|
|
isMinimized?: boolean;
|
|
};
|
|
|
|
export type GitHubReviewComment = GitHubComment & {
|
|
path: string;
|
|
line: number | null;
|
|
};
|
|
|
|
export type GitHubCommit = {
|
|
oid: string;
|
|
message: string;
|
|
author: {
|
|
name: string;
|
|
email: string;
|
|
};
|
|
};
|
|
|
|
export type GitHubFile = {
|
|
path: string;
|
|
additions: number;
|
|
deletions: number;
|
|
changeType: string;
|
|
};
|
|
|
|
export type GitHubReview = {
|
|
id: string;
|
|
databaseId: string;
|
|
author: GitHubAuthor;
|
|
body: string;
|
|
state: string;
|
|
submittedAt: string;
|
|
updatedAt?: string;
|
|
lastEditedAt?: string;
|
|
comments: {
|
|
nodes: GitHubReviewComment[];
|
|
};
|
|
};
|
|
|
|
export type GitHubPullRequest = {
|
|
title: string;
|
|
body: string;
|
|
author: GitHubAuthor;
|
|
baseRefName: string;
|
|
headRefName: string;
|
|
headRefOid: string;
|
|
isCrossRepository: boolean;
|
|
headRepository: {
|
|
owner: {
|
|
login: string;
|
|
};
|
|
name: string;
|
|
} | null;
|
|
createdAt: string;
|
|
updatedAt?: string;
|
|
lastEditedAt?: string;
|
|
additions: number;
|
|
deletions: number;
|
|
state: string;
|
|
labels: {
|
|
nodes: Array<{
|
|
name: string;
|
|
}>;
|
|
};
|
|
commits: {
|
|
totalCount: number;
|
|
nodes: Array<{
|
|
commit: GitHubCommit;
|
|
}>;
|
|
};
|
|
files: {
|
|
nodes: GitHubFile[];
|
|
};
|
|
comments: {
|
|
nodes: GitHubComment[];
|
|
};
|
|
reviews: {
|
|
nodes: GitHubReview[];
|
|
};
|
|
};
|
|
|
|
export type GitHubIssue = {
|
|
title: string;
|
|
body: string;
|
|
author: GitHubAuthor;
|
|
createdAt: string;
|
|
updatedAt?: string;
|
|
lastEditedAt?: string;
|
|
state: string;
|
|
labels: {
|
|
nodes: Array<{
|
|
name: string;
|
|
}>;
|
|
};
|
|
comments: {
|
|
nodes: GitHubComment[];
|
|
};
|
|
};
|
|
|
|
export type PullRequestQueryResponse = {
|
|
repository: {
|
|
pullRequest: GitHubPullRequest;
|
|
};
|
|
};
|
|
|
|
export type IssueQueryResponse = {
|
|
repository: {
|
|
issue: GitHubIssue;
|
|
};
|
|
};
|