#!/usr/bin/env sh set -eu repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || { echo "FAIL: 当前目录不在 Git 仓库中。" >&2 exit 1 } hook_file="$repo_root/.githooks/commit-msg" if [ ! -f "$hook_file" ]; then echo "FAIL: 未找到提交门禁:$hook_file" >&2 exit 1 fi chmod +x "$hook_file" git -C "$repo_root" config --local core.hooksPath .githooks configured_path=$(git -C "$repo_root" config --local --get core.hooksPath) if [ "$configured_path" != ".githooks" ]; then echo "FAIL: Git hooksPath 配置校验失败,当前值:$configured_path" >&2 exit 1 fi echo "PASS: 已为当前克隆启用 Git 中文提交门禁(core.hooksPath=.githooks)。"