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