An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          


Logo

BRACK: The Relentless Git Branch Name Acknowledger


License: MIT
Donate

> **/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.