echo "Running cargo fmt..."
cargo fmt --all
if ! git diff --quiet; then
echo "✓ Code formatted. Adding changes to commit..."
git diff --name-only | grep '\.rs$' | xargs -r git add
fi
echo ""
echo "Running cargo clippy..."
if ! cargo clippy --all-targets --all-features -- -D warnings; then
echo "❌ Clippy checks failed. Please fix the warnings above."
exit 1
fi
echo "✓ Clippy checks passed"
echo ""
echo "Checking version sync..."
if ! ./scripts/check-version-sync.sh; then
echo "❌ Version sync check failed. Commit aborted."
exit 1
fi
echo ""
./scripts/replace-version-placeholders.sh
if ! git diff --quiet docs/; then
echo "✓ Version placeholders replaced. Adding doc changes to commit..."
git diff --name-only docs/ | grep '\.md$' | xargs -r git add
fi
echo "✓ Pre-commit hook completed"