fix(ci): detach HEAD 释放本地分支名,避开 fork PR 同名冲突#464
Merged
Conversation
PR #451 (来自 fork aeoform/openless, head ref 也叫 beta) 触发 @claude 时, claude-code-action 执行 `git fetch origin pull/451/head:beta` 把 PR head 拉到本地 beta 分支,但此时 worktree 正 checkout 在 refs/heads/beta, git 拒绝 fetch 到已 checkout 的分支: fatal: refusing to fetch into branch 'refs/heads/beta' checked out at ... Action failed with error: Command failed: git fetch origin --depth=20 pull/451/head:beta 修复: 在 actions/checkout 后立即 git checkout --detach,释放 refs/heads/<default-branch> 这个本地分支名,让 action 自己 fetch 不撞名. 仅在 fork head ref == base ref name 的 corner case 才会触发问题, detach 对其他场景无副作用. 失败 run: https://github.com/Open-Less/openless/actions/runs/25978532215
PR Reviewer Guide 🔍(Review updated until commit 00cffb3)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit 00cffb3 |
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.
User description
背景
PR #451 (fork
aeoform/openless, head ref 也叫beta) 上有人 @claude,云端 review action 失败:错误链:
根因(三连命中才会触发)
isCrossRepository: true)beta—— 与本仓库 base / 默认分支同名actions/checkout@v4默认把 worktree checkout 到了refs/heads/betaclaude-code-action@v1内部执行:把 PR head 拉到本地同名分支
beta(命名取自 fork 端 head ref name)。但beta已是当前 checked-out 分支,git 拒绝 fetch 到已 checkout 的分支 → 失败。修复
在
actions/checkout之后立即git checkout --detach,释放refs/heads/<default-branch>这个本地分支名,让 action 自己 fetch 不撞名。仅对 fork head ref == base ref name 这个 corner case 有影响;其他场景(本仓库分支、fork 分支名不同)detach 都是无副作用的。
改动
.github/workflows/claude.yml: +11 行,单 step + 注释,无其他改动。Test plan
@claude,确认 action run 成功,不再出现refusing to fetch into branch错误@claude,确认正常路径不退化PR Type
Bug fix
Description
Detach checkout before Claude action
Free default branch ref on forks
Prevent fetch collisions in CI
Diagram Walkthrough
File Walkthrough
claude.yml
Detach HEAD before Claude review step.github/workflows/claude.yml
git checkout --detachstep after repository checkout.claude-code-actionfrom fetching into an already checked-outbranch.
comments.