#!/usr/bin/env bash
# Point this clone at .githooks so pre-push runs scripts/ci-local.sh.
# Called by `make up` and `make hooks`. Idempotent.
# No-op outside a git checkout (zip copy, image build) so `make up` still starts.
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

if ! git rev-parse --git-dir >/dev/null 2>&1; then
  exit 0
fi

git config core.hooksPath .githooks
chmod +x .githooks/pre-push scripts/ci-local.sh scripts/check-coding-standard.sh

echo "pre-push hook enabled (core.hooksPath=.githooks)"
echo "Bypass once: SKIP_LOCAL_CI=1 git push"
