Skip to main content

Create git hooks with ease using a simple configuration file in a git project

Project description

py-githooks

code linting: flake8 code quality: pytest MIT license CircleCI Coverage Status Dependabot badge

Create git hooks with ease using a simple configuration file in a git project

Install

pip install py-githooks

Usage

  1. Create a .githooks.ini configuration file (If not provided a dummy configuration file will be created).
  2. Add sections based on git hooks names followed by a command property with the shell code you want to run.
  3. Run either python -m python_githooks or githooks 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

  1. Running python -m python_githooks --deactivate or githooks --deactivate will stop shimming git hooks but keep the commands in .git/hooks
  2. Run rm .githooks.ini to remove the configuration file (optional).
  3. 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


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.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

py_githooks-1.1.1-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page