chore(V5.7): 增加中文提交信息校验门禁

This commit is contained in:
Codex
2026-08-11 03:07:45 +08:00
parent fd6be4f9b9
commit 2de796143f
7 changed files with 353 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#!/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)。"