https://github.com/kraymer/brack
The branch name acknowledger. Git pre-commit hook to enforce a branches naming policy.
https://github.com/kraymer/brack
branch git
Last synced: about 1 month ago
JSON representation
The branch name acknowledger. Git pre-commit hook to enforce a branches naming policy.
- Host: GitHub
- URL: https://github.com/kraymer/brack
- Owner: Kraymer
- License: mit
- Created: 2021-01-04T09:17:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-16T20:37:20.000Z (almost 4 years ago)
- Last Synced: 2025-04-04T00:33:38.005Z (8 months ago)
- Topics: branch, git
- Language: Shell
- Homepage:
- Size: 146 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

BRACK: The Relentless Git Branch Name Acknowledger
> **/bɹək/** :
>
> 1. *n.* efficient tracking dog of the foxhound family. Friendly and not very intelligent.
> 2. *n.* git pre-commit hook to enforce a branch naming policy across your project. Portmanteau word for **Br**anch **Ack**nowledger.
`brack` is a plugin for [pre-commit](https://github.com/pre-commit/pre-commit) that rejects commits when branch name does not validate a predefined format.
### Installation
Copy `pre_commit_hooks/brack` to your `.git/hooks/` folder and rename it as `pre-commit`.
Or if you use [pre-commit](https://github.com/pre-commit/pre-commit) framework, add this to your `.pre-commit-config.yaml` :
```yaml
- repo: https://github.com/kraymer/brack
rev: main
hooks:
- id: brack
```
### Configuration
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, ""]
~~~
Beware that regex must be compliant with [POSIX Basic Regular Syntax](https://en.wikipedia.org/wiki/Regular_expression#POSIX).
### Alternative
[no_commit_to_branch](https://github.com/pre-commit/pre-commit-hooks/blob/master/pre_commit_hooks/no_commit_to_branch.py) 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.