From 21e3fe05427933846a17301b2f7e2ca64eb94e2e Mon Sep 17 00:00:00 2001 From: Sol Redfern <59831933+Tsuesun@users.noreply.github.com> Date: Wed, 11 Feb 2026 01:52:32 +0900 Subject: [PATCH] Fix PR checkout to support fork PRs (#851) Use GitHub's PR refs (pull/NUMBER/head) instead of fetching branch by name. This works for both same-repo and fork PRs because GitHub automatically creates these refs in the base repository for all PRs. The branch name doesn't exist on origin for fork PRs, causing: fatal: couldn't find remote ref Using pull/${entityNumber}/head:${branchName} fetches the PR head and creates a local branch with the correct name. Fixes issues with tag mode failing on fork PRs. --- src/github/operations/branch.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/github/operations/branch.ts b/src/github/operations/branch.ts index 86197da..a228a3d 100644 --- a/src/github/operations/branch.ts +++ b/src/github/operations/branch.ts @@ -166,7 +166,13 @@ export async function setupBranch( // Execute git commands to checkout PR branch (dynamic depth based on PR size) // Using execFileSync instead of shell template literals for security - execGit(["fetch", "origin", `--depth=${fetchDepth}`, branchName]); + // Use GitHub's PR ref which works for both same-repo and fork PRs + execGit([ + "fetch", + "origin", + `--depth=${fetchDepth}`, + `pull/${entityNumber}/head:${branchName}`, + ]); execGit(["checkout", branchName, "--"]); console.log(`Successfully checked out PR branch for PR #${entityNumber}`);