- .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.
26 lines
872 B
Bash
Executable file
26 lines
872 B
Bash
Executable file
#!/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."
|