Prefix jira id in every commit message using husky hook
git cm
in the gif is a shortcut for git commit -m
customized by myself, no magic 😄
for NPM users:
npm i git-hook-jira-id -D
for YARN users:
yarn add git-hook-jira-id --dev
Usage:
$ git-hook-jira-id [options]
Options:
-p, --prefix <prefix> jira prefix
-i, --interactive interactive
-h, --help Display this message
-v, --version Display version number
prefix
It's used for matching jira id from your branch name
for example
git-hook-jira-id -p ABC
Internally it will use /ABC-\d+/i
for searching jira id
interactive
If you want to prefix jira id case by case
interactive
may be your best choice
- without
--interactive
, it will add jira id for every commit, it's simple but powerful
"husky": {
"hooks": {
"prepare-commit-msg": "git-hook-jira-id -p <PREFIX>"
}
}
- with
--interactive
, you can make your own decision for every commit
"husky": {
"hooks": {
"prepare-commit-msg": "exec < /dev/tty && git-hook-jira-id -p <PREFIX> -i || true"
}
}
Remember to replace <PREFIX>
with your own prefix