#!/usr/bin/env bash
set -euo pipefail

export PATH="$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"

repo_root="$(git rev-parse --show-toplevel)"
cd "$repo_root"

run() {
  printf '\n==> %s\n' "$*"
  "$@"
}

printf 'Checking repository before commit in %s\n' "$repo_root"

run git status --short
run git diff --check
run git diff --cached --check
run git diff --cached --stat
run git diff --stat

run uv run tests/run.py --local

printf '\nPre-commit quality checks passed.\n'
