#!/bin/bash
# Pre-commit hook for northroot-engine
# Runs fast checks: formatting and basic validation

set -e

echo "🔍 Running pre-commit checks..."

# Check formatting
echo "  ✓ Checking formatting..."
if ! cargo fmt --all -- --check; then
    echo "❌ Code is not formatted. Run 'cargo fmt --all' to fix."
    exit 1
fi

# Check for common issues
echo "  ✓ Checking for common issues..."
if git diff --cached --name-only | grep -q 'Cargo.toml'; then
    echo "  ⚠ Cargo.toml changed - ensure version is updated if needed"
fi

# Check for TODO/FIXME in staged files (warn only)
if git diff --cached --name-only | xargs grep -l "TODO\|FIXME" 2>/dev/null; then
    echo "  ⚠ Warning: Found TODO/FIXME in staged files"
fi

echo "✅ Pre-commit checks passed"
exit 0

