pre-commit hooks for Rust tools.
First, install the pre-commit Python package.
Second, create a .pre-commit-config.yaml
file in the top level of your Git-based project with the following content:
- repo: https://github.com/berquist/pre-commit-rust
rev: main
hooks:
- id: cargo-fmt
- id: cargo-check
- id: cargo-clippy
- id: cargo-test
Finally, install the pre-commit hook locally and run it for the first time:
pre-commit install
pre-commit run -a
- repo: https://github.com/berquist/pre-commit-rust
rev: main
hooks:
- id: cargo-fmt
args: ['--verbose', '--', '--edition', '2018' ]
Note: cargo fmt
picks up "edition" automatically from Cargo.toml
, so specifying this isn't necessary in most cases.