- #!/usr/bin/env bash
- # 知识库提交前校验:暂存区含 docs/参考资料/知识库 变更时自动运行校验脚本。
- # 阻断不合规提交(返回非 0 时 git commit 会失败),可用 git commit --no-verify 跳过。
- set -euo pipefail
- ROOT="$(git rev-parse --show-toplevel)"
- KB_DIR="docs/参考资料/知识库"
- VALIDATOR="$ROOT/docs/scripts/validate_kb.py"
- if git diff --cached --name-only -- "$KB_DIR" | grep -q .; then
- echo "[pre-commit] 检测到知识库变更,运行校验: $VALIDATOR"
- python3 "$VALIDATOR" "$ROOT/$KB_DIR"
- fi
|