#!/bin/sh
# Pre-commit hook: lint and test before every commit
# Install: git config core.hooksPath .githooks

set -e

PYTHON_BIN="${PYTHON_BIN:-python3}"
if [ -x ".venv/bin/python" ]; then
  PYTHON_BIN=".venv/bin/python"
fi
export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}src"

echo "Running ruff lint..."
"$PYTHON_BIN" -m ruff check src/ tests/

echo "Running tests..."
"$PYTHON_BIN" -m pytest tests/ -q --tb=line -x

echo "All checks passed."
