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.
This commit is contained in:
parent
36179affdd
commit
200668c51b
5 changed files with 54 additions and 35 deletions
26
.githooks/pre-commit
Executable file
26
.githooks/pre-commit
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/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."
|
||||
Loading…
Add table
Add a link
Reference in a new issue