tippspiel2027/.githooks/pre-commit
torsten 200668c51b Map-Pflege per Commit-Hook absichern
- .githooks/pre-commit erzeugt docs/code-map.md bei Code-Commits neu und
  staged sie mit; laeuft nur bei tippspiel/ oder tools/*.php|py.
- Map-Kopf ohne Commit-Hash: --check vergleicht Baum und Map jetzt exakt.
- README/AGENTS.md: Aktivierung per 'git config core.hooksPath .githooks'
  und Hinweis, dass die AGENTS.md-Regel ohne Hook weiterhin gilt.
2026-11-06 07:17:29 +01:00

26 lines
872 B
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# Hält docs/code-map.md automatisch aktuell.
#
# Aktivieren (einmalig pro Clone):
# git config core.hooksPath .githooks
#
# Läuft nur, wenn Code im Commit ist (tippspiel/ oder tools/*.php|py).
# Erzeugt die Map aus dem Arbeitsstand und staged sie mit.
set -e
cd "$(git rev-parse --show-toplevel)"
if ! git diff --cached --name-only --diff-filter=ACMR \
| grep -qE '^(tippspiel/|tools/.*\.(php|py)$)'; then
exit 0
fi
# Die Map wird aus dem Arbeitsbaum erzeugt, nicht aus dem Index. Bei
# teilweise gestagten Änderungen kann sie deshalb mehr enthalten als der Commit.
if [ -n "$(git diff --name-only -- tippspiel tools)" ]; then
echo "Hinweis: nicht gestagte Code-Änderungen – docs/code-map.md beschreibt den Arbeitsstand." >&2
fi
./tools/gen_codemap.py >/dev/null
git add docs/code-map.md
echo "docs/code-map.md neu erzeugt und gestaged."