tippspiel2027/.githooks/pre-commit
torsten ac0b840dc0 Commit-Hook ohne python3 nicht blockieren
Fehlt python3 (frischer Rechner), bricht der Hook den Commit nicht ab,
sondern weist darauf hin, dass die Code-Map nicht erneuert wurde.
README nennt Python 3 als Voraussetzung fuer die Werkzeuge.
2026-11-06 07:20:09 +01:00

32 lines
1.1 KiB
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
# Ein fehlendes python3 darf keinen Commit blockieren.
if ! command -v python3 >/dev/null 2>&1; then
echo "Hinweis: python3 fehlt – docs/code-map.md wurde nicht erneuert (siehe README)." >&2
exit 0
fi
./tools/gen_codemap.py >/dev/null
git add docs/code-map.md
echo "docs/code-map.md neu erzeugt und gestaged."