#!/bin/sh

echo "Running pre-commit hooks..."

# Run clippy and fix warnings (includes formatting via mise fix-all)
echo "Running clippy and fixing warnings..."
mise run fix-all
if [ $? -ne 0 ]; then
    echo "❌ Clippy check failed. Please fix the remaining warnings before committing."
    exit 1
fi

# Re-add any files that were modified by the fixes
echo "Re-adding modified files to commit..."
git add -A

echo "✅ All checks passed and fixes applied!"
exit 0
