feat(auto-push): add local git hooks for pre-commit validation and

autopush

- Add pre-commit hook to enforce structural validation before commit
- Add post-commit hook for resilient Gitea auto-push and offline
  tolerance
- Add scripts/install-hooks.sh to configure core.hooksPath
This commit is contained in:
kiskaadee committed 2026-09-09 17:15:45 -05:00
1 parent 1914482efd
commit e5600c05ad
3 files changed
+49

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -u
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "$REPO_ROOT"
BRANCH="$(git branch --show-current)"
if [ -z "$BRANCH" ]; then
echo "⚠️ [post-commit] Detached HEAD detected; skipping auto-push."
exit 0
fi
echo "🚀 [post-commit] Syncing '${BRANCH}' to origin..."
if git push origin "$BRANCH"; then
echo "✨ [post-commit] Brain synchronized successfully."
else
echo "⚠️ [post-commit] Push failed (network or remote unreachable)."
echo "ℹ️ [post-commit] Commit remains saved locally. Run 'git push' when online to synchronize."
fi
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -u
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "$REPO_ROOT"
echo "🔍 [pre-commit] Validating Brain structure..."
if python3 scripts/validate-brain.py; then
echo "✅ [pre-commit] Brain structure valid."
else
echo "❌ [pre-commit] Brain validation failed. Commit aborted."
echo "💡 [pre-commit] Fix structural issues or move uncurated drafts into inbox/."
exit 1
fi
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${REPO_ROOT}"
chmod +x .githooks/pre-commit .githooks/post-commit
git config core.hooksPath .githooks
echo "✅ Git hooks configured successfully:"
echo " • core.hooksPath set to .githooks"
echo " • pre-commit: structural validation via validate-brain.py"
echo " • post-commit: auto-push to origin"