| set -euo pipefail | |
| ROOT=$(git rev-parse --show-toplevel 2>/dev/null || { echo "Not in a git repo"; exit 1; }) | |
| HOOK_DIR="$ROOT/.git/hooks" | |
| mkdir -p "$HOOK_DIR" | |
| cat > "$HOOK_DIR/post-commit" <<'SH' | |
| #!/usr/bin/env bash | |
| BR=$(git rev-parse --abbrev-ref HEAD) | |
| if [ -n "$SKIP_AUTO_PUSH" ]; then exit 0; fi | |
| if [ -x "mlops/sync/push_all.sh" ]; then | |
| bash mlops/sync/push_all.sh "$BR" | |
| fi | |
| SH | |
| chmod +x "$HOOK_DIR/post-commit" | |
| echo "[hooks] Installed post-commit auto-push (set SKIP_AUTO_PUSH=1 to disable)" | |