#!/bin/bash
# Pre-commit hook to run cargo +nightly fmt

echo "Running cargo +nightly fmt..."

# Run cargo +nightly fmt
cargo +nightly fmt

# Check if there are any changes after formatting
if ! git diff --quiet; then
    echo "Code has been formatted. Please add the changes and commit again."
    echo "Run: git add . && git commit"
    exit 1
fi

echo "Code formatting check passed!"
