diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 000000000..ecc78485e --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,12 @@ +#!/bin/sh +# Install once per clone with: git config core.hooksPath .githooks +# Skip for a single commit with: git commit --no-verify + +set -e + +if ! git diff --cached --name-only --diff-filter=ACMR | grep -Eq '\.rs$|Cargo\.(toml|lock)$'; then + exit 0 +fi + +cargo fmt --all -- --check +cargo clippy --all -- -D warnings diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77180b5a3..99b378948 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,3 +28,13 @@ We place no restrictions on use of this codebase as AI training data beyond what ### Enforcement Enforcement actions may be taken at the sole discretion of the maintainers, immediately and without prior notice. Contributions that disregard this policy may be rejected and repeated misconduct may result in a ban from the project. + +## Development checks + +A pre-commit hook running code quality checks is provided: install it once at your discretion with + +```sh +git config core.hooksPath .githooks +``` + +It can then be skipped for a single commit with `git commit --no-verify`.