set -e
echo "Running pre-commit checks..."
if ! command -v cargo &> /dev/null; then
echo "Error: cargo is not available. Please install Rust and Cargo."
exit 1
fi
echo "🔍 Checking code formatting..."
if ! cargo fmt --all -- --check; then
echo "❌ Code formatting check failed!"
echo "💡 Please run 'cargo fmt --all' to fix formatting issues."
exit 1
fi
echo "✅ Code formatting is correct"
echo "🔍 Running clippy checks..."
if ! cargo clippy --all-targets --all-features -- -D warnings 2>/dev/null; then
echo "⚠️ Clippy check completed with warnings (some known issues may exist)"
echo "💡 Consider reviewing clippy suggestions, but this won't block the commit"
else
echo "✅ Clippy checks passed"
fi
echo "✅ All pre-commit checks completed successfully!"
exit 0