From 148cc611ecf11b5eb56a6b7b5c18e77215159f82 Mon Sep 17 00:00:00 2001 From: Erwan Legrand Date: Sat, 19 Sep 2026 14:23:12 +0200 Subject: [PATCH] chore: add a pre-commit hook mirroring CI's fmt and clippy checks --- .githooks/pre-commit | 12 ++++++++++++ CONTRIBUTING.md | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 .githooks/pre-commit 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`.