File size: 517 Bytes
0daf510 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#!/usr/bin/env bash
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)"
|