/bɹək/ :
- n. efficient tracking dog of the foxhound family. Friendly and not very intelligent.
- n. git pre-commit hook to enforce a branch naming policy across your project. Portmanteau word for Branch Acknowledger.
brack
is a plugin for pre-commit that rejects commits when branch name does not validate a predefined format.
Copy pre_commit_hooks/brack
to your .git/hooks/
folder and rename it as pre-commit
.
Or if you use pre-commit framework, add this to your .pre-commit-config.yaml
:
- repo: https://github.com/kraymer/brack
rev: main
hooks:
- id: brack
By default branch name must match the regex "^(feature|bugfix|improvement|library|prerelease|release|hotfix)\/[a-z0-9._-]+$"
.
If you prefer to use a custom regex, edit your .pre-commit-config.yaml
to give it as argument to the script :
- id: brack
args: [-r, "<YOUR_REGEX>"]
Beware that regex must be compliant with POSIX Basic Regular Syntax.
no_commit_to_branch is a hook provided with pre-commit that accomplishes the same thing but the logic is reversed : you define a regex that matches the branches you want NOT authorize commit to.
Depending on your usage, picking one or the other might facilitate maintenance of the regex.