Skip to main content

This is nabla_custom hooks package

Project description


License Gitter Minimal java version

Jenkins build Status Travis Build Status Quality Gate

Nabla custom git hooks

This project intend to be uses by all Nabla products

Table of contents


This hooks requires the following to run:

See requirements.txt for mandatory packages.

This pre-commit hooks requires the following to run:

Install nabla-hooks as a developer

Using virtualenv

Install python 3.8 and virtualenv

virtualenv --no-site-packages /opt/ansible/env38 -p python3.8
source /opt/ansible/env38/bin/activate

pip3.8 install -r hooks/requirements.txt -r requirements.testing.txt

Install nabla-hooks to use it

Using Pip

pip install nabla-hooks

From Source

pip install git+

Add .pre-commit-config.yaml in you git project

  1. create .pre-commit-config.yaml in you git project

example .pre-commit-config.yaml as following:

-   repo:
    rev: v1.0.0
    - id: git-branches-check

Testing locally

-   repo: local
    -   id: git-branches-check
        name: GIT branches check
        description: Check for old stale and already merged branches from the current repo with user friendly messages and colors
        entry: pre_commit_hooks/
        language: script
        types: [shell]
        always_run: true
        verbose: true
        args: [--max=1, --verbose]

$ pre-commit try-repo . git-branches-check --verbose

  1. Install in your repo

Run pre-commit install pre-commit install -f --install-hooks

  1. enjoy it

Run pre-commit run --all-files

Run SKIP=flake8 git commit -am 'Add key' Run git commit -am 'Add key' --no-verify

Override global environement variable


See jira

With user/pass

export JIRA_USER=aandrieu
export JIRA_URL=https://localhost/jira
export JIRA_CERT_PATH=/etc/ssl/certs/NABLA-CA-1.crt
export JIRA_CERT_PATH=/etc/ssl/certs/ca-certificates.crt

#### With email/token

export JIRA_PASSWORD=XXX # the token you generated
export JIRA_URL==https://localhost/jira
export JENKINS_URL=https://localhost/jenkins/
export JENKINS_USER=aandrieu

The Templates Directories

See git-hooks-using-python


First time run

cp -r hooks/* .git/hooks/` or `rm -Rf ./.git/hooks/ && ln -s ../hooks ./.git/hooks && git checkout thisrepo hooks/


We have two directories that interest us:

The /usr/share/git-core/templates/ directory on Linux and C:/Program Files (x86)/Git/share/git-core/templates/ directory on Windows (Note that on 32bit machines msysGit is installed by default on 'C:/Program Files/…') in which the default hooks are being copied from. If you installed Git using another configuration the installation might reside in a different folder. Adjust the path accordingly.

The .git/hooks/ directory is the directory in which the hooks templates are being copied to.

The hooked are being copied from the [...]/share/git-core/templates/ directory. There are other types of templates but they are out of scope for this post.

Note: If you change the templates directory the hooks directory must be a subdirectory of the templates directory. Do not set the templates directory to the desired hooks directory instead.


git config --global init.templatedir /workspace/users/albandrieu30/nabla-hooks/

Package nabla-hooks as a developer

See setup-cfg

Build a source distribution (a tar archive of all the files needed to build and install the package):

python3 sdist Builds wheels: python3 bdist_wheel Build from source: python3 build And install: /opt/ansible/env38/bin/python3 install

sudo python develop pip install . pip install -e ./

Upload a source distribution

See api-tokens

python3 sdist bdist_wheel nano $HOME/.pypirc python3 -m twine upload --repository testpypi dist/*

Uploaded nabla-hooks

Test nabla-hooks as a developer

shell usage


from hooks import get_msg match_msg


tox --notest
tox -e py  # Run tox using the version of Python in PATH
tox py38

From root directory

export PYTHONPATH=hooks
pytest --cache-clear --setup-show test/

Visual Code

Add PYTHONPATH=hooks for pytest when inside visual studio

export PYTHONPATH=hooks
code .

Update Table of Contents

npm install --save markdown-toc

brew install github-markdown-toc gh-md-toc --insert

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

nabla_hooks-1.0.2.tar.gz (56.3 kB view hashes)

Uploaded source

Built Distribution

nabla_hooks-1.0.2-py2.py3-none-any.whl (22.2 kB view hashes)

Uploaded py2 py3

Supported by

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