Install make based git hooks with ease.
When working on Node.js projects, I liked the simplicity of setting up git hooks using husky. Since I failed to find a similar tool in python ecosystem, I decided to write one myself.
As far as I know, there is no standard equivalent to npm scripts in python, so I chose to rely on make which seems to be a popular way to organise project-related tasks in the python world.
Development follows my needs at work, which means whippet might be a bit light on features. Feel free to make a suggestion if you’re missing something.
$ pip install whippet
Once whippet is installed, it is used by invoking whippet executable in the directory where you wish to install hooks. Whippet checks if that directory (or its ancestor) contains a .git directory and offers to install hooks into it.
$ cd demo $ whippet whippet - Are you sure you want to install hooks in /home/bpp/demo/.git? [Y/n] y
Whippet hooks are scripts that check for the existence of make targets with the same name as git hooks. If such a target exists, the script executes it. Let’s take pre-commit as an example. Once whippet hooks are installed, we simply add pre-commit target to the Makefile like so:
pre-commit: @echo "Whippet says: Woof!"
Then the target will be executed on pre-commit:
$ git commit -m 'Testing whippet' pre-commit Whippet says: Woof! [master d654d33] Bar 1 file changed, 12 insertions(+) create mode 100644 Makefile $
If you had enough and want to remove whippet git hooks invoke whippet and pass uninstall command
$ whippet uninstall whippet - Are you sure you want to uninstall hooks in /home/bpp/demo/.git? [Y/n] y
To avoid the prompt pass the --assume-yes argument to whippet. This can be useful when adding whippet to initialisation target in Makefile. Example:
init: poetry install whippet --assume-yes
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size whippet-0.3.2-py3-none-any.whl (5.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size whippet-0.3.2.tar.gz (5.1 kB)||File type Source||Python version None||Upload date||Hashes View hashes|