Gathering detailed insights and metrics for my-prepare-commit-msg
Gathering detailed insights and metrics for my-prepare-commit-msg
Gathering detailed insights and metrics for my-prepare-commit-msg
Gathering detailed insights and metrics for my-prepare-commit-msg
Husky Git hook to add JIRA ticket ID into the commit message.
npm install my-prepare-commit-msg
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (95.08%)
JavaScript (4.92%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
121 Stars
827 Commits
37 Forks
3 Watchers
8 Branches
9 Contributors
Updated on May 06, 2025
Latest Version
1.1.0
Package Id
my-prepare-commit-msg@1.1.0
Unpacked Size
30.43 kB
Size
9.00 kB
File Count
8
NPM Version
6.14.16
Node Version
12.22.12
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
18
The husky command to add JIRA ticket ID into the commit message if it is missed.
The JIRA ticket ID is taken from a git branch name.
Installing Jira prepare commit msg hook into your project will mean everyone contributing code to your project will automatically tag each commit with it's associated issue key based off the branch name.
So if your branch name is feature/TEST-123-new-feature
, then when you commit with a message "initial commit"
it will automatically become "TEST-123: initial commit"
.
Why would you want this? Well, Jira has many hidden goodies, and this is one of them! If you include an issue key in your commit messages AND you have your deployment pipeline connected to Jira this will unlock many bonus features, such as the Deployments view, Cycle time report, Deployment frequency report and I've heard many more features are coming soon!
Install the package using NPM
1npm install husky jira-prepare-commit-msg --save-dev && npx husky install
For Husky 5:
Execute command
1npx husky add .husky/prepare-commit-msg 'npx jira-prepare-commit-msg $1'
For Husky 2-4:
Inside your package.json add a standard husky npm script for the git hook
1{ 2 "husky": { 3 "hooks": { 4 "prepare-commit-msg": "jira-prepare-commit-msg" 5 } 6 } 7}
Starting with v1.3 you can now use different ways of configuring it:
jira-prepare-commit-msg
object in your package.json
.jirapreparecommitmsgrc
file in JSON or YML formatjira-prepare-commit-msg.config.js
file in JS formatSee cosmiconfig for more details on what formats are supported.
package.json
example:1{ 2 "jira-prepare-commit-msg": { 3 "messagePattern": "[$J] $M", 4 "jiraTicketPattern": "([A-Z]+-\\d+)", 5 "commentChar": "#", 6 "isConventionalCommit": false, 7 "allowEmptyCommitMessage": false, 8 "gitRoot": "", 9 "allowReplaceAllOccurrences": true, 10 "ignoredBranchesPattern": "^(master|main|dev|develop|development|release)$", 11 "ignoreBranchesMissingTickets": false 12 } 13}
jira-prepare-commit-msg
supports special message pattern to configure where JIRA ticket number will be inserted.
$J
will be replaced on JIRA ticket number$M
will be replaced on commit message.Pattern [$J]\n$M
is currently supported by default.
1{ 2 "jira-prepare-commit-msg": { 3 "messagePattern": "[$J]\n$M" 4 } 5}
[$J] $M
[$J]-$M
$J $M
NOTE: the supplied commit message will be cleaned up by strip
mode.
jira-prepare-commit-msg
supports by default replacing all occurrences variables in message pattern.
1{ 2 "jira-prepare-commit-msg": { 3 "allowReplaceAllOccurrences": true 4 } 5}
If set the message pattern to [$J] $M. \n Line for CI ($J): $M
, then all occurrences will be replaced:
[JIRA-1234] test message.
Line for CI (JIRA-1234): test message
jira-prepare-commit-msg
allows using custom regexp string pattern to search JIRA ticket number.
Pattern ([A-Z]+-\\d+)
is currently supported by default.
NOTE: to search JIRA ticket pattern flag i
is used: new RegExp(pattern, i')
1{ 2 "jira-prepare-commit-msg": { 3 "jiraTicketPattern": "([A-Z]+-\\d+)" 4 } 5}
Git uses #
by default to comment lines in the commit message. If default char was changed jira-prepare-commit-msg
can allow set it.
1{ 2 "jira-prepare-commit-msg": { 3 "commentChar": "#" 4 } 5}
The commit message might be empty after cleanup or using -m ""
, jira-prepare-commit-msg
might insert the JIRA ticket number anyway if this flag is set.
1{ 2 "jira-prepare-commit-msg": { 3 "allowEmptyCommitMessage": true 4 } 5}
The git root folder might be set. It is either absolute path or relative path which will be resolved from cwd
1{ 2 "jira-prepare-commit-msg": { 3 "gitRoot": "./../../" 4 } 5}
The package will search commit message so:
1const pathToGit = path.resolve(cwd, './../../'); 2const pathToCommitMessage = path.join(pathToGit, '.git', 'COMMIT_EDITMSG');
Branches can be ignored and skipped by regex pattern string
1{ 2 "jira-prepare-commit-msg": { 3 "ignoredBranchesPattern": "^main|develop|(maint-.*)$" 4 } 5}
Moreover, this can be solved by replacing the Husky hook. Put in your prepare-commit-msg file (husky git hook):
1#!/bin/sh 2. "$(dirname "$0")/_/husky.sh" 3 4if [[ "$(git rev-parse --abbrev-ref HEAD)" =~ YOUR_BRANCH_REGEX ]]; then 5npx --no-install jira-prepare-commit-msg $1 6fi
where YOUR_BRANCH_REGEX
e.g. ^(feature|(bug|hot)fix)\/[A-Z]+-[0-9]+$
Be silent and skip any branch with missing jira ticket
1{ 2 "jira-prepare-commit-msg": { 3 "ignoreBranchesMissingTickets": true 4 } 5}
jira-prepare-commit-msg
supports conventional commit. To insert JIRA
ticket number to the description set the following setting:
1{ 2 "jira-prepare-commit-msg": { 3 "isConventionalCommit": true 4 } 5}
NOTE: For description will be applied messagePattern
If the configuration is:
1{ 2 "jira-prepare-commit-msg": { 3 "messagePattern": "[$J] $M", 4 "isConventionalCommit": true 5 } 6}
and commit message is fix(test)!: important changes
then at result will be fix(test)!: [JIRA-1234] important changes
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More