Skip to content

Commit 8ca4558

Browse files
committed
document pre-commit in contributing
1 parent 58575cc commit 8ca4558

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ pip install flake8
8585
flake8 --exclude venv ./
8686
```
8787

88+
### Pre-commit hooks
89+
ro-crate-py comes with a configuration file for [pre-commit](https://github.com/pre-commit/pre-commit) `.pre-commit-config.yaml`.
90+
This configuration file defines so-called "hooks" which are executed upon each commit, to automatically format the code in the commited files according to the requirements defined for instance in the flake8 configuration file (e.g removing spaces from blank lines...).
91+
92+
To benefit from these automated hooks, you need first to install the pre-commit package.
93+
`pip install pre-commit`
94+
95+
The hooks should then be installed once for your local copy of the repository by running the following command in the root of the repo.
96+
`pre-commit install`
97+
98+
Once installed the hooks will be executed each time a new commit is made, for the files being commited.
99+
If some checks failed or could not be fixed automatically, an error message will be shown and the commit will be aborted.
100+
101+
While not recommended, you can bypass the hooks by passing the additional flag `--no-verify` to the `git commit` command.
102+
103+
Some IDEs have plugins for precommit (e.g [here](https://marketplace.visualstudio.com/items?itemName=elagil.pre-commit-helper) for VSCode), which would for instance run the hooks for the currently opened file each time it is saved. The plugins typically picks up the configuration file automatically.
104+
88105
### Testing
89106

90107
Testing is done with [pytest](https://pytest.org):

0 commit comments

Comments
 (0)