Files
second-brain/.githooks/post-commit
T
kiskaadee e5600c05ad 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
2026-09-09 17:15:45 -05:00

22 lines
596 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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