From c7d9228a8816e8f0ef32ff798d040a1ed0907e7c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Brule Date: Sun, 8 Mar 2026 11:29:59 -0400 Subject: [PATCH] chore: add post-commit repo registry hook Co-Authored-By: Svrnty Inc. --- lefthook.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lefthook.yml b/lefthook.yml index 3f358b3..7472393 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -44,6 +44,29 @@ commit-msg: printf '\n\nCo-Authored-By: Svrnty Inc. \n' >> "{1}" fi +post-commit: + commands: + register-repo: + run: | + REPO_NAME=$(basename "$(git rev-parse --show-toplevel)") + ROOT_CLAUDE="$(git rev-parse --show-toplevel)/../CLAUDE.md" + [ -f "$ROOT_CLAUDE" ] || exit 0 + if grep -qF "| \`$REPO_NAME\`" "$ROOT_CLAUDE"; then + exit 0 + fi + COMMIT=$(git rev-parse --short HEAD) + DATE=$(date +%Y-%m-%d) + TOTAL_LINE=$(grep -n '^\*\*Total:' "$ROOT_CLAUDE" | head -1 | cut -d: -f1) + if [ -z "$TOTAL_LINE" ]; then + exit 0 + fi + OLD_COUNT=$(sed -n "${TOTAL_LINE}p" "$ROOT_CLAUDE" | grep -oP '\d+') + NEW_COUNT=$((OLD_COUNT + 1)) + sed -i "${TOTAL_LINE}i| \`${REPO_NAME}\` | — | NEW REPO — registered ${DATE} (${COMMIT}). Update stack and purpose. |" "$ROOT_CLAUDE" + NEW_TOTAL_LINE=$((TOTAL_LINE + 1)) + sed -i "${NEW_TOTAL_LINE}s/Total: ${OLD_COUNT}/Total: ${NEW_COUNT}/" "$ROOT_CLAUDE" + echo "REGISTRY: added '$REPO_NAME' to root CLAUDE.md (${DATE}, ${COMMIT})" + pre-push: commands: protect-main: