From 2a12e9c46bda11c564d15374a5d4ac27e64a337a Mon Sep 17 00:00:00 2001 From: Anastasia Lubennikova Date: Wed, 22 Nov 2023 12:04:36 +0000 Subject: [PATCH] Add documentation for our sample pre-commit hook (#5868) --- CONTRIBUTING.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5de7842f1a..2692684006 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,6 +9,24 @@ refactoring, additional comments, and so forth. Let's try to raise the bar, and clean things up as we go. Try to leave code in a better shape than it was before. +## Pre-commit hook + +We have a sample pre-commit hook in `pre-commit.py`. +To set it up, run: + +```bash +ln -s ../../pre-commit.py .git/hooks/pre-commit +``` + +This will run following checks on staged files before each commit: +- `rustfmt` +- checks for python files, see [obligatory checks](/docs/sourcetree.md#obligatory-checks). + +There is also a separate script `./run_clippy.sh` that runs `cargo clippy` on the whole project +and `./scripts/reformat` that runs all formatting tools to ensure the project is up to date. + +If you want to skip the hook, run `git commit` with `--no-verify` option. + ## Submitting changes 1. Get at least one +1 on your PR before you push.