This project is a fork of the compilerla/conventional-pre-commit repository, which applies pre-commit hooks to enforce the use of Conventional Commits.
This fork adds the following features:
-
Ignore Conventional Commits Check on MERGE:
- The Conventional Commits check is automatically ignored when the git stage involves a MERGE. This prevents unnecessary failures during branch integration.
-
Prohibit Commits on the
main
Branch:- Commits are blocked when attempting to commit directly to the
main
branch, enforcing best practices by encouraging the use of feature branches. Apre-commit
hook to check commit messages for Conventional Commits formatting.
- Commits are blocked when attempting to commit directly to the
Works with Python >= 3.8.
Make sure pre-commit
is installed.
Create a blank configuration file at the root of your repo, if needed:
touch .pre-commit-config.yaml
Add a new repo entry to your configuration file:
repos:
# - repo: ...
- repo: https://github.com/hbranco/conventional-pre-commit
rev: <git sha or tag>
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
Install the pre-commit
script:
pre-commit install --hook-type commit-msg
Unistall the pre-commit
script:
pre-commit unistall
Inspired by matthorgan's pre-commit-conventional-commits
.