https://github.com/robatwilliams/git-ticket-number-prefix-hook
Automatically prefixes commit messages with ticket number from the branch name
https://github.com/robatwilliams/git-ticket-number-prefix-hook
git git-hooks jira
Last synced: about 2 months ago
JSON representation
Automatically prefixes commit messages with ticket number from the branch name
- Host: GitHub
- URL: https://github.com/robatwilliams/git-ticket-number-prefix-hook
- Owner: robatwilliams
- Created: 2017-11-04T12:16:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-29T21:04:02.000Z (over 6 years ago)
- Last Synced: 2025-03-21T00:31:34.343Z (over 1 year ago)
- Topics: git, git-hooks, jira
- Language: Shell
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git commit message ticket number prefix hook
Automatically prefixes commit messages with ticket number from the branch name.
The current regular expression suits the JIRA style of ticket number: `ABC-123`. Commits made to a branch whose name starts with that pattern will have their message prefixed.
Review the unit tests to learn about other features and behaviour.
## Shell and JavaScript variants
JavaScript: easier for me to write, and hopefully easier for you to modify should you need to.
Shell (Bash): doesn't need Node.js, and ~10% faster.
## Installation
Copy `commit-msg` from `hooks/` to the `.git/hooks` folder in your repository clone folder.
You may want to look up automated hook sharing approaches such as using the `core.hooksPath` configuration variable.
## Tests
The hook is tested in a fixture Git repository. Tests are implemented and run using the [BATS](https://github.com/bats-core/bats-core/) framework; each one is a small shell script.
```bash
# Install BATS
git clone https://github.com/bats-core/bats-core.git
# Run tests
./test.sh
./test.sh [variant]
```
## Want to go further?
* [commitizen](https://github.com/commitizen/cz-cli)
* [commitlint](https://github.com/marionebl/commitlint)