From d8ff1c71187dae278960f691e516c682ed15c13c 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 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc695d8c..009c3d52 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,19 +1,24 @@ # 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> poetry shell -(duniterpy-UyTOfZjU-py3.9) pre-commit install +duniterpy> pre-commit run isort --all-files ``` ### Black formatting -- GitLab