Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
#!/bin/sh
# pre-commit:
# 0. Self-update: reinstall if .github/hooks/pre-commit is newer than the installed copy
# 1. Portability checks (non-ASCII, PS backtick escapes) on staged files
# 2. Auto-regen llms-full.txt when any of its inputs are staged
#
# Works on Windows (Git Bash), Linux, and macOS.

# ============================================================================
# Part 0: self-update
# ============================================================================
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
if [ -n "$REPO_ROOT" ]; then
HOOK_SRC="$REPO_ROOT/.github/hooks/pre-commit"
HOOK_DST="$REPO_ROOT/.git/hooks/pre-commit"
if [ -f "$HOOK_SRC" ] && [ -f "$HOOK_DST" ] && [ "$HOOK_SRC" -nt "$HOOK_DST" ]; then
cp "$HOOK_SRC" "$HOOK_DST"
chmod +x "$HOOK_DST"
echo "pre-commit: hook updated from .github/hooks -- re-running"
exec "$HOOK_DST" "$@"
fi
fi

STAGED=$(git diff --cached --name-only --diff-filter=ACM)
[ -z "$STAGED" ] && exit 0

Expand Down
Loading