Skip to content

Running

Precommit takes advantage of something called "Git Hooks", which exists in your local .git/ folder per repository. These "hooks" allow Precommit to run wheneve you attempt a commit. Precommit should be listed as a dev dependency on every CHIME FRB/SPS project, so if you simply follow the Poetry tutorial and enter the shell with poetry shell, you can access Precommit.

Whenever you first clone/create a repository, to add the .git/ hook, you'll have to run

Text Only
pre-commit install

or

Text Only
poetry run pre-commit install

if you're not in the Poetry virtual environment shell.

If you'd like to have Precommit installed globally on your local deivce, you can simply install it with pip, using:

Text Only
pip install pre-commit

It is important to note that Precommit only runs on staged changed files (files modified and staged with git add). Although, you can run it on all files with

Text Only
pre-commit run --all-files

to test your entire repository.