Files
Joseph MattielloandClaude Opus 5.5 e671501f85 ci(release): hook + release guide cover the fallback header; checker nits
Review on #795:
- Copilot: the pre-commit hook ran check-info-version.sh only for
  dist/info/ or Makefile changes; version_fallback.h now triggers it too.
- Copilot: docs/release-process.md still said to bump only the Makefile
  and check only .info; both places now name all three copies.
- Kimi: missing-file check for all three inputs, set -eu, and the version
  parse stops at the first closing quote (a trailing comment on the
  #define no longer leaks into the value -- tested with a mismatch).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-04 09:22:23 -04:00

45 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# Install git hooks for this repository.
#
# Currently installs a pre-commit that runs:
# - scripts/c89-lint.sh on staged .c files (catches MSVC C89 violations)
# - scripts/check-info-version.sh if anything under dist/info/ or
# Makefile is staged (verifies display_version stays in sync)
# - yamllint on staged .yml/.yaml files (skipped if yamllint isn't
# installed -- CI runs it unconditionally)
#
# Skip with `git commit --no-verify` if you really need to (e.g., a WIP
# squash); CI will catch it later anyway.
set -e
HOOK_DIR="$(git rev-parse --git-dir)/hooks"
cat > "$HOOK_DIR/pre-commit" << 'HOOK'
#!/bin/sh
set -e
STAGED=$(git diff --cached --name-only --diff-filter=ACM)
# C89 lint on staged .c files
STAGED_C=$(echo "$STAGED" | grep '\.c$' || true)
if [ -n "$STAGED_C" ]; then
scripts/c89-lint.sh $STAGED_C
fi
# Version sync check: Makefile, .info and the fallback header (#734)
if echo "$STAGED" | grep -qE '^(dist/info/|Makefile$|src/core/version_fallback\.h$)'; then
scripts/check-info-version.sh
fi
# yamllint on staged YAML files (only if yamllint is on PATH; CI runs
# it unconditionally so it's fine to skip locally when missing).
STAGED_YAML=$(echo "$STAGED" | grep -E '\.ya?ml$' || true)
if [ -n "$STAGED_YAML" ] && command -v yamllint >/dev/null 2>&1; then
yamllint $STAGED_YAML
fi
HOOK
chmod +x "$HOOK_DIR/pre-commit"
echo "Installed pre-commit hook (C89 lint + .info version check + yamllint)"