6df453f057
复用 CI 同款检查的快子集,提交前本地拦截: - .githooks/pre-commit:红线词 + 可移植SQL + codegen 漂移(成功静默/失败打详情) - ci/install-hooks.sh:一键启用(core.hooksPath=.githooks) - 不放 flutter/go test(慢,留 CI 闸4);可 --no-verify 临时跳过 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
643 B
Bash
Executable File
19 lines
643 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# install-hooks.sh — 启用本地 git hooks(闸 3:提交前把关)。
|
|
#
|
|
# 一次性运行即可;之后每次 git commit 会自动跑 .githooks/pre-commit
|
|
# (红线词 + 可移植 SQL + codegen 漂移)。失败会中止提交。
|
|
#
|
|
# 卸载: git config --unset core.hooksPath
|
|
set -euo pipefail
|
|
|
|
ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$ROOT"
|
|
|
|
git config core.hooksPath .githooks
|
|
chmod +x .githooks/* 2>/dev/null || true
|
|
|
|
echo "✓ 已启用 git hooks(core.hooksPath=.githooks)"
|
|
echo " pre-commit 将跑:红线词扫描 · 可移植 SQL 扫描 · codegen 漂移检查"
|
|
echo " 卸载:git config --unset core.hooksPath"
|