chore: add post-commit repo registry hook
Co-Authored-By: Svrnty Inc. <jp@svrnty.io>
This commit is contained in:
parent
313b8c83ea
commit
c7d9228a88
23
lefthook.yml
23
lefthook.yml
@ -44,6 +44,29 @@ commit-msg:
|
|||||||
printf '\n\nCo-Authored-By: Svrnty Inc. <jp@svrnty.io>\n' >> "{1}"
|
printf '\n\nCo-Authored-By: Svrnty Inc. <jp@svrnty.io>\n' >> "{1}"
|
||||||
fi
|
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:
|
pre-push:
|
||||||
commands:
|
commands:
|
||||||
protect-main:
|
protect-main:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user