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
22 lines
596 B
Bash
Executable File
22 lines
596 B
Bash
Executable File
#!/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
|