collin/anvil
| 1 | #!/bin/sh |
| 2 | # Pre-commit: rustfmt (nightly, for the unstable options in rustfmt.toml) + clippy. |
| 3 | # Wired up via `git config core.hooksPath .githooks`. |
| 4 | set -e |
| 5 | |
| 6 | if ! cargo +nightly fmt --all -- --check >/dev/null 2>&1; then |
| 7 | cargo +nightly fmt --all |
| 8 | echo "pre-commit: rustfmt reformatted files — review, re-stage, and commit again." >&2 |
| 9 | git diff --name-only -- '*.rs' >&2 |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | cargo clippy --workspace --all-targets -- -D warnings |