#!/bin/sh
# Refuses a commit whose Rust is not as rustfmt writes it. Clippy is left to the checks before a
# push (CLAUDE.md, Tests): it is a build, and Tower's builds go one at a time.
git diff --cached --name-only --diff-filter=ACM | grep -q '\.rs$' || exit 0
cargo fmt --all --check >/dev/null 2>&1 && exit 0
echo "pre-commit: the Rust is not formatted; run cargo fmt --all" >&2
exit 1
