Pre-commit
Install
To install the pre-commit Python library, you can run the following command:
pip install --user pre-commit
Configure
Copy the pre-commit file .pre-commit-config.yaml
to the root of your
git repository.
Here is the C pre-commit config that you will have to use:
repos:
- repo: local
hooks:
- id: clang-format
name: coding style
entry: clang-format --Werror --dry-run
language: system
files: \.(c|h)$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: trailing-whitespace
exclude: ^tests/
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
hooks:
- id: forbid-binary
You can then run:
pre-commit install
tip
You may add more pre-commit hooks, the list of all supported hooks can be found here: https://pre-commit.com/hooks.html
Going further
For more information, you may look through the documentation: https://pre-commit.com/