#!/bin/bash
# Pre-commit hook to ensure Rust code is formatted
#
# To install this hook, run:
#   cp scripts/git-hooks/pre-commit .git/hooks/pre-commit
#   chmod +x .git/hooks/pre-commit
#
# Or use the installation script:
#   ./scripts/install-git-hooks.sh

echo "Running cargo fmt check..."
cargo fmt --all -- --check

if [ $? -ne 0 ]; then
    echo ""
    echo "❌ Code formatting check failed!"
    echo "Please run 'cargo fmt' to format your code before committing."
    exit 1
fi

echo "✅ Code formatting check passed!"
exit 0
