feat(ci): add pre-commit FactId validation hook (#393)
Grep-based pre-commit check validating fact_id references in content YAML against canonical knowledge catalogs. Runs in advisory mode when catalogs are stubs (exit 0), switches to enforcing mode once populated (exit 1 on unknown fact_ids with file:line output). - tooling/check-fact-ids: core validation script (<2s runtime) - .config/hooks/pre-commit: hook dispatcher for modular checks - Makefile: check-fact-ids + setup-hooks targets, wired into setup - docs/DEVOPS.md: content validation and pre-commit hooks sections Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pre-commit hook dispatcher. Runs modular checks from tooling/.
|
||||
# Installed via: git config core.hooksPath .config/hooks
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
ERRORS=0
|
||||
|
||||
run_check() {
|
||||
local script="$1"
|
||||
local label="$2"
|
||||
if [ -x "$REPO_ROOT/$script" ]; then
|
||||
if ! "$REPO_ROOT/$script"; then
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
else
|
||||
echo "pre-commit: skipping $label ($script not found or not executable)"
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Checks ---
|
||||
run_check "tooling/check-fact-ids" "fact_id validation"
|
||||
|
||||
if [ "$ERRORS" -gt 0 ]; then
|
||||
echo ""
|
||||
echo "pre-commit: $ERRORS check(s) failed. Commit aborted."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user