#!/usr/bin/env bash
#
# Purpose: Suggested pre-push gate to run CI-parity checks before pushing.
# Exports: N/A (git hook entry point).
# Role: Local-only safety net for humans/agents; CI remains authoritative.
# Invariants: Blocks push when the repo's CI-parity command fails.
# Invariants: Prints a short invariants reminder banner.
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)"
if [[ -z "${repo_root}" ]]; then
  echo "error: not in a git repo" >&2
  exit 1
fi

banner_path="${repo_root}/docs/suggested-hooks/banner.txt"
if [[ -f "${banner_path}" ]]; then
  cat >&2 <"${banner_path}"
fi

if ! command -v just >/dev/null 2>&1; then
  echo "error: 'just' not found; install it or run CI checks manually:" >&2
  echo "  just ci" >&2
  exit 1
fi

echo "pre-push: running CI-parity checks: just ci" >&2
just ci

