#!/bin/sh # 安装本地 git 钩子(每台机器跑一次)。把 git 的 pre-commit 接到仓库内 # scripts/hooks/pre-commit(设计系统守门闸)。钩子是本地的,不随 git 同步—— # 故需各机器各跑一次本脚本。 set -e hooks_dir="$(git rev-parse --git-path hooks)" mkdir -p "$hooks_dir" target="$hooks_dir/pre-commit" cat > "$target" <<'SH' #!/bin/sh # 委托到仓库内 scripts/hooks/pre-commit(随当前 worktree 的 checkout 走; # 不存在则放行,便于尚未合入该脚本的分支/worktree)。 hook="$(git rev-parse --show-toplevel)/scripts/hooks/pre-commit" [ -x "$hook" ] && exec "$hook" exit 0 SH chmod +x "$target" echo "[ds-gate] ✓ 已安装 pre-commit 钩子 → $target" echo "[ds-gate] 今后提交若动了 design/prototype/ 会自动跑 12 道设计系统闸。"