https://github.com/boreplusplus/whippet
Install make based hooks with ease.
https://github.com/boreplusplus/whippet
git git-hooks hooks make python
Last synced: about 1 year ago
JSON representation
Install make based hooks with ease.
- Host: GitHub
- URL: https://github.com/boreplusplus/whippet
- Owner: BorePlusPlus
- License: mit
- Created: 2019-09-10T03:54:35.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-13T17:10:38.000Z (over 6 years ago)
- Last Synced: 2025-05-05T12:45:33.123Z (about 1 year ago)
- Topics: git, git-hooks, hooks, make, python
- Language: Python
- Size: 64.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
Whippet - like husky, but leaner
################################
Use `make `_ targets to execute git hooks. Inspired by `husky `_.
.. image:: https://travis-ci.org/BorePlusPlus/whippet.svg?branch=master
:target: https://travis-ci.org/BorePlusPlus/whippet
:alt: Automatic build
.. image:: https://img.shields.io/pypi/v/whippet
:target: https://pypi.org/project/whippet/
:alt: PyPI version
.. image:: https://img.shields.io/pypi/dw/whippet
:target: https://pypi.org/project/whippet/
:alt: 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 `_.
.. code-block:: bash
$ 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.
.. code-block:: bash
$ 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:
.. code-block:: make
pre-commit:
@echo "Whippet says: Woof!"
Then the target will be executed on ``pre-commit``:
.. code-block:: bash
$ 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
.. code-block:: bash
$ 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:
.. code-block:: make
init:
pip install -r requirements.txt
whippet --assume-yes