Skip to content

Commit 9c4c065

Browse files
matthallett1claude
andcommitted
[.github] Fix claude-review fork fetch — point origin to fork repo
claude-code-action@v1 unconditionally runs `git fetch origin <branch>` even when the branch is already checked out locally. For fork PRs, the branch doesn't exist on the base repo's origin. Fix: after checking out the PR code, repoint origin to the fork's repo URL so the action's internal fetch finds the branch. For same-repo PRs this is a no-op. Existing refs (origin/main etc.) are preserved from the initial checkout. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b9ff3b6 commit 9c4c065

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

.github/workflows/claude-review.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ jobs:
4949
BRANCH=$(gh pr view "${PR_NUMBER}" --json headRefName -q .headRefName)
5050
git checkout -B "${BRANCH}" refs/remotes/origin/pr-head
5151
52+
# Point origin to the fork repo so claude-code-action can fetch the branch.
53+
# For same-repo PRs this is a no-op (URL stays the same).
54+
FORK_URL=$(gh pr view "${PR_NUMBER}" --json headRepository -q '.headRepository.url')
55+
if [ -n "$FORK_URL" ]; then
56+
git remote set-url origin "${FORK_URL}"
57+
fi
58+
5259
- uses: anthropics/claude-code-action@v1
5360
with:
5461
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)