工程+文档(车道铁律): worktree 铁律改两车道——代码面(game/非.md)唯一强制 worktree,其余主区直改;新增 git pre-commit 直改闸(版本化+hooksPath+LF钉死+在位自检);AGENTS/process-conventions/architecture 三处规则同步
This commit is contained in:
1 parent
2d699feeac
commit
f2b17b47bd
6 files changed
+84
-17
No files matched your search
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# 直改车道闸(git pre-commit,2026-10-26 车道铁律)——staged 不含代码面的提交,提交点现场跑
|
||||
# 文档域闸(tools/run_all_gates.sh --docs,秒级文本扫描):绿=落地,红=中止。
|
||||
# 代码面=game/ 下非 .md 的行为载体(判据与改动域划分同一)。staged 含代码面时:
|
||||
# 主工作区=拦(代码面唯一合法路径=worktree 批合回);任务 worktree=跳过(归批末闸+合回闸管,
|
||||
# 不打扰迭代批中间提交)。--no-verify 绕过仅属用户(agent 侧由 worktree-guard 拦截)。
|
||||
set -u
|
||||
REPO="$(git rev-parse --show-toplevel)"
|
||||
|
||||
# staged 路径集(首提交无 HEAD 时对 --root 比);空集放行,交回 git 自身报「无改动可提」
|
||||
if git rev-parse --verify -q HEAD >/dev/null 2>&1; then
|
||||
STAGED="$(git diff --cached --name-only)"
|
||||
else
|
||||
STAGED="$(git diff --cached --name-only --root)"
|
||||
fi
|
||||
[ -z "$STAGED" ] && exit 0
|
||||
|
||||
# 代码面判定:staged 里任一路径落在 game/ 且非 .md
|
||||
if printf '%s\n' "$STAGED" | grep '^game/' | grep -viE '\.md$' | grep -q .; then
|
||||
# 主区判定:git-dir 与 common-dir 同一=主工作区(非链接 worktree)
|
||||
_GD="$(cd "$(git rev-parse --git-dir)" && pwd)"
|
||||
_CD="$(cd "$(git rev-parse --git-common-dir)" && pwd)"
|
||||
if [ "$_GD" = "$_CD" ]; then
|
||||
echo "[直改闸] 主工作区禁止直提代码面(game/ 下非 .md)——代码面改动走迭代批独立 worktree(git worktree add ../g-plan2-<任务名> -b <任务分支>),收尾在主工作区 git merge --no-ff 合回。" >&2
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RC=0
|
||||
bash "$REPO/tools/run_all_gates.sh" --docs || RC=$?
|
||||
if [ "$RC" -eq 0 ]; then
|
||||
exit 0
|
||||
elif [ "$RC" -eq 1 ]; then
|
||||
echo "[直改闸] 文档域闸有新增红,提交已拦。修上方红项后重新 commit,钩子会自动重跑闸;禁跑代码域/游戏类测试,与本次红项无关。" >&2
|
||||
else
|
||||
echo "[直改闸] 闸脚本自身故障(退出码 $RC),不是文档红——把本输出原样呈报用户,勿改文档、勿跑替代测试。" >&2
|
||||
fi
|
||||
exit 1
|
||||
@@ -58,6 +58,21 @@ done
|
||||
# 与基线比必判「红项清单变化」假红)、末尾汇总自身崩掉打不出结论。
|
||||
export PYTHONIOENCODING=utf-8
|
||||
|
||||
# ── 直改闸在位自检(车道铁律):pre-commit 钩子失位=主区直改提交静默免验,任何跑批点红暴露 ──
|
||||
_HP="$(git -C "$REPO" config core.hooksPath)"
|
||||
if [ -n "$_HP" ]; then
|
||||
case "$_HP" in /*) _HPT="$_HP/pre-commit" ;; *) _HPT="$REPO/$_HP/pre-commit" ;; esac
|
||||
if [ ! -f "$_HPT" ]; then
|
||||
echo "[gates] FAIL — core.hooksPath=$_HP 但 pre-commit 文件缺位:直改闸失位,主区直改提交免验。"
|
||||
echo " 处置:确认 tools/hooks/pre-commit 在位后 git config core.hooksPath tools/hooks"
|
||||
exit 1
|
||||
fi
|
||||
elif [ ! -f "$(git -C "$REPO" rev-parse --git-path hooks)/pre-commit" ]; then
|
||||
echo "[gates] FAIL — core.hooksPath 未设置且默认钩子位无 pre-commit:主区直改提交免验。"
|
||||
echo " 自愈:git config core.hooksPath tools/hooks"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 代码面(game/ 下非 .md 的行为载体)是否带着未提交改动(只算已跟踪文件——闸件自身产物都落在
|
||||
# gitignore 面)。脏树跑出来的回执记的是 HEAD,验的却是别的字节,合回闸据此拒收。
|
||||
DIRTY_GAME=0
|
||||
|
||||
Reference in new issue
Block a user