Skip to main content

Whippet - like husky, but leaner

Use make targets to execute git hooks. Inspired by husky.

Automatic build PyPI version PyPI downloads

Rationale

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.

Note

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.

Installation

Whippet is available as a PyPI package. Use a tool that can install packages from it, like for instance pip.

$ pip install whippet

Usage

Install hooks

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

Setup target

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
$

Uninstall hooks

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

Non-interactive

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

Metadata

Release files for whippet 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whippet 0.3.2
File Size Uploaded
whippet-0.3.2.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for whippet 0.3.2
File Interpreter ABI Platform
whippet-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / whippet-0.3.2.tar.gz

Download URL whippet-0.3.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d450e4f279af436ed2fa431ff12e2820e6361ac41d51c30e2b69242499c0cb82
BLAKE2b-256 checksum
How to use checksums
e02cf7327f99f1284c3c256cd6bd87d615e05c95bc5905a46e640202b7364ca9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.6.7 Linux/4.15.0-1028-gcp

Release files / whippet-0.3.2-py3-none-any.whl

Download URL whippet-0.3.2-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de06836b8e4af756eb61f6006db3195e346271ec3840c381647747c784387162
BLAKE2b-256 checksum
How to use checksums
e722acaa5604ac8975c3b8cd8b4bc56e5422b59e8b5f7b40e0fcb2eac7d0faa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.6.7 Linux/4.15.0-1028-gcp

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page