#!/bin/bash
# Pre-commit hook: run ruff check + ruff format on staged Python files.
# Set up with: git config core.hooksPath .githooks

set -e

py_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$' || true)

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

ruff check $py_files
ruff format --check $py_files
