Create git hooks with ease using a simple configuration file in a git project
Project description
py-githooks
Create git hooks with ease using a simple configuration file in a git project
Install
pip install py-githooks
Usage
- Create a
.githooks.ini
configuration file (If not provided a dummy configuration file will be created). - Add sections based on
git hooks names
followed by acommand
property with the shell code you want to run. - Run either
python -m python_githooks
orgithooks
in your virtual environment.
Configuration file example:
# .githooks.ini
[pre-commit]
command = pytest --cov
[pre-push]
command = pytest --cov && flake8
Removing a hook
If you already created a hook and now want to remove it, just set the command value to empty, like this:
# .githooks.ini
[pre-commit]
command =
This will not actually physically remove the hook from the git local project, just will make it instantly exit with 0
status code.
Unuse
- Running
python -m python_githooks --deactivate
orgithooks --deactivate
will stop shimming git hooks but keep the commands in.git/hooks
- Run
rm .githooks.ini
to remove the configuration file (optional). rm .git/hooks/pre-commit
or any other githook to stop them from executing (optional). e.g.rm .git/hooks/*
License
py-githooks is MIT-licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-githooks-1.1.0.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for py_githooks-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 490300652f93196c4450326cac2af3b1b043f72423cc5e5c146932ce8bef6e48 |
|
MD5 | b17755b444c1a5da034546d8a056915e |
|
BLAKE2b-256 | be782374239027834f52c185f2f5b578a52cb92c94fd37cf285d992830a8c15b |