13.2. Git Pre-Commit Hooks#

Itom makes use of pre-commit hooks for identifying simple issues such as missing semicolons, trailing whitespace or misspellings before submission to git. The pre-commit hooks are run before each commit and your commit can fail accordingly.

After cloning the |itom| repositories (itomProject or itom, plugins, designerPlugins) hooks must be install e.g. using pip.

python -m pip install pre_commit

Git hooks must be installed into the .git folder of each repo.

python -m pre_commit install

Pre_commits can be executed manually:

python -m pre-commit run --all-files

A practical tip is to also run pre_commits manually to reduce frustration when you want or need to create a commit. Failed hooks ensure that a commit cannot be set.

To execute specific hooks, their names can be passed as an additional argument (e.g. codespell).

python -m pre-commit run --all-files codespell