The purpose of this pre-commit hook is to prevent accidental commits in a specified list of branches, e.g. master
, develop
, etc.
If this is your first time configuring pre-commit
, follow the installation instructions:
https://pre-commit.com/#install
Add this to your .pre-commit-config.yaml
file under the repos
key:
- repo: https://github.com/PaperNick/pre-commit-forbidden-branches
rev: 0.3.0
hooks:
- id: forbid-commits-hook
args: ['master']
pass_filenames: false
You can use the args
key to specify more than one branch:
args: ['master', 'develop']
Create a virtual environment:
python3 -m venv venv/
Activate the venv:
source venv/bin/activate
Install the development requirements:
pip install -r requirements_dev.txt
Run the tests:
python -m pytest tests/ --cov pre_commit_hook/
bash tests/integration/run.sh