#!/usr/bin/env bash
# Pre-commit hook: fast checks on staged Python files.
# Catches lint and format issues before they reach CI.
set -e

# Only check staged .py files
STAGED_PY=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$' || true)

if [ -z "$STAGED_PY" ]; then
  exit 0
fi

echo "pre-commit: checking ${STAGED_PY##*$'\n'} ($(echo "$STAGED_PY" | wc -l | tr -d ' ') files)..."

# Lint staged files
echo "$STAGED_PY" | xargs uv run ruff check --no-fix
echo "$STAGED_PY" | xargs uv run ruff format --check

echo "pre-commit: passed"
