Repository navigation
docs(skills): 统一 git-branch / git-worktree 的 base 解析 (#335) - #340
Open
Casper-Mars wants to merge 1 commit into
Open
Casper-Mars wants to merge 1 commit into
Casper-Mars wants to merge 1 commit into
Conversation
原因:git-worktree 把 base 硬编码为 main,默认分支是 master/trunk 的仓库 要么选错(陈旧 main)要么选不到(无 main);两处各自表述也必然漂移。 改动: - git-branch 新增 ## Base 段作为唯一事实源:documented base → origin/HEAD → 用户指定 → main 兜底,每级先用 git rev-parse --verify --quiet 校验 ref - 给出可执行片段 ref_exists / resolve_base - git-worktree base 段改为引用 git-branch 规则,片段逐字节复制; 创建时 origin/<base> 优先、其次本地 <base>;解析失败列候选、提示 --base <branch>、非零退出,禁止静默按不存在的 main 继续 验证:fixture A(master 默认分支 + origin/HEAD + 无 main)worktree HEAD == origin/master;陈旧 main 不误选;无可用 base 非零退出;两文件片段 diff 为空; .github 两个 unittest 目录 533 + 14 条全绿
This was referenced Nov 4, 2026
This branch has not been deployed
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.
Fixes #335
Summary
git-worktree把 base 硬编码为main:默认分支是master/trunk的仓库要么选错(本地存在陈旧main),要么直接选不到 base;两处 SKILL 各写一套 base 规则,也必然漂移。.agents/skills/git-branch/SKILL.md新增## Base段,作为 base 解析的唯一事实源:documented base → origin/HEAD → 用户指定(--base)→ main 兜底,每级先用ref_exists()(git rev-parse --verify --quiet "origin/$1"优先,其次refs/heads/$1)校验,不可用降级到下一级;并给出可执行的ref_exists/resolve_base片段(git symbolic-ref refs/remotes/origin/HEAD,取不到时回落git remote show origin)。.agents/skills/git-worktree/SKILL.md的 base 段改为引用 git-branch 规则(片段逐字节复制,不再自带第二套表述);创建前解析 base,origin/<base>优先、其次本地<base>;解析失败列候选、提示--base <branch>、非零退出,禁止静默按不存在的main继续。原「Default the base tomain」硬编码删除。origin/HEAD优先于用户显式--base的顺序后果也在文中点名(评审若认为应改为用户优先,需先改 AC/方案)。.github/skills下无同源镜像;install.sh不用改(其sync_skills整目录复制.agents/skills);worktree 路径段不动(属 bug: 从仓库子目录调用 git-worktree 会把 worktree 创建到错误目录 #336)。Testing
fixture 用真 git 仓库跑,并从 SKILL.md 的
## Base段现场抽取 bash 片段执行(证明文档片段本身可用)。被测内容与本地已验证提交逐字节一致(git diff <verified-sha> HEAD -- .agents/为空)。仓库回归(
python:3.12-slim,Python 3.12.16,与 CI 同版本):(本分支基于
feature/AICF-1,不含 #334 的 7 条新增用例,故为 526 而非 533。)Risk
install.sh会把.agents/skills整目录同步到目标仓库,措辞即安装指引,评审应当在合并前确认语义;origin/HEAD先于用户--base的顺位按 AC4 保留,显式--base不会覆盖可解析的origin/HEAD——这是已知语义缺口,已在文档中写明;.agents/skills/git-worktree/SKILL.md的路径段(本 PR 刻意未动路径逻辑),合并顺序建议先 bug: git-worktree 在默认分支不是 main 的目标仓库中会选错或选不到 base #335 再 bug: 从仓库子目录调用 git-worktree 会把 worktree 创建到错误目录 #336。How to revert
Revert 本 PR 的 merge commit;无数据、配置或安装脚本迁移。