#!/usr/bin/env bash
# .githooks/pre-push — catch the two cheap mistakes locally; CI does the rest.
#
# Runs:
#   1. cargo fmt --all --check                                  (~1s)
#   2. cargo clippy --workspace --all-targets -- -D warnings    (~6s warm, ~35s cold)
#
# Skip with:  git push --no-verify   (genuine WIP only)
# Activate:   git config core.hooksPath .githooks

set -euo pipefail

if ! cargo fmt --all --check; then
    echo "✗ fmt: run 'cargo fmt --all'" >&2
    exit 1
fi
echo "✓ fmt"

if ! cargo clippy --workspace --all-targets -- -D warnings; then
    echo "✗ clippy: fix warnings, or 'git push --no-verify' for WIP" >&2
    exit 1
fi
echo "✓ clippy"
