#!/usr/bin/env bash
# Claw Code local pre-push safety gate.
#
# Install with:
#   git config core.hooksPath .github/hooks
#
# This intentionally mirrors the CI build gate so stale field/enum references are
# caught before pushing to main or PR branches.
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel 2>/dev/null)"
cd "$repo_root"

if [[ ! -f rust/Cargo.toml ]]; then
  echo "pre-push: rust/Cargo.toml not found; skipping cargo workspace build" >&2
  exit 0
fi

echo "pre-push: cargo build --manifest-path rust/Cargo.toml --workspace" >&2
cargo build --manifest-path rust/Cargo.toml --workspace
