From 5a32d9c124a8bee149ea769dac158c8258e509f9 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Wed, 12 May 2021 18:41:52 +0200 Subject: [PATCH] [doc] #162, #165: Change pre-commit hooks documentation Update hooks in used Install pre-commit via 'apt' or pip Recommended way to install it outside of poetry virtualenv Document how to 'run' tools installed into pre-commit virtualenv --- CONTRIBUTING.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 279475ce..ab618514 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,19 +1,28 @@ # Contribute guide ## Pre-commit -We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing. Such as black formatting. -Depending whether you prefer to work ouside or inside Poetry virtual environment, you should stick to one usage or use both to still have this usefull checks. -`pre-commit` can be used from the installation on your system or from inside Poetry virtual environment where it is installed. +We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing. +We are using it for `black` formatting, `isort` imports sorting, `pylint` code linting, `mypy` typing, and `gitlab-ci` linting. + +Install `pre-commit` from your distribution. In case it is an outdated version, install it from `pip`: +```bash +sudo apt install pre-commit +pip install --user pre-commit +``` To install the `git-hooks`, run: ```bash -pip3 install --user pre-commit duniterpy> pre-commit install ``` +Then each time you commit changes, the hooks will perform checks. +To manually run one of the tool above, run (eg for `isort`): +```bash +duniterpy> pre-commit run --all-files isort +``` +To run all checks on all files: ```bash -duniterpy> poetry shell -(duniterpy-UyTOfZjU-py3.9) pre-commit install +duniterpy> pre-commit run -a ``` ### Black formatting -- GitLab