Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
branch-commit-msg
Advanced tools
A git commit-msg hook that automatically inserts a matched pattern from the active branch name to the commit message.
branch-commit-msg
is a git commit-msg hook that extracts a configurable regex pattern from the current branch and reformats the final commit message to the configured format.
With no dependency:
$ npx branch-commit-msg install
With husky:
$ npm install -D branch-commit-msg
$ npx husky add .husky/commit-msg 'npx branch-commit-msg-hook "$1"'
With no dependency:
$ rm .git/hooks/commit-msg
With husky:
Remove npx branch-commit-msg-hook "$1"
from .husky/commit-msg
and run:
$ npm uninstall branch-commit-msg
After installation, create a .commitmsgrc.json
file at the root of your project and configure how you would like to reformat your final commit message based on elements of the active branch name:
// .commitmsgrc.json
{
/*
Regex group pattern to extract from branch name.
- ex: "(sc)-?[0-9]+"
*/
"extractPattern": string,
/*
Whether the extractPattern is case-sensitive.
- ex: true
*/
"extractPatternMatchCase": boolean,
/*
Final output format for the commit message.
Formatting Placeholders:
%b0: access the entire matched pattern from the branch name
%b1: access the first matched group pattern from the branch name
%bn: access the 'n'th matched group pattern from the branch name
- ex: "%b6" accesses the 6th matched group pattern
%m: the original commit message
Pipes:
lower: applies lower casing to the formatting placeholder
- ex: "$b2 | lower"
upper: applies upper casing to the formatting placeholder
- ex: "%m | upper"
*/
"commitMsgFormat": string
}
After your .commitmsgrc.json
is configured, start making commits!
{
"extractPattern": "sc-[0-9]+",
"extractPatternMatchCase": false,
"commitMsgFormat": "%b0 - %m"
}
# Current branch: SC-123456/my-new-feature
$ git commit -m "added a thing"
$ git log -1 --pretty=%B
# Output: SC-123456 - added a thing
{
"extractPattern": "SOMEPRJ-[0-9]+",
"extractPatternMatchCase": false,
"commitMsgFormat": "%m (%b0 | upper)"
}
# Current branch: feature/someprj-123456
$ git commit -m "added a thing"
$ git log -1 --pretty=%B
# Output: added a thing (SOMEPRJ-123456)
{
"extractPattern": "(some).*(complex[0-9-]+).*(branch)",
"extractPatternMatchCase": false,
"commitMsgFormat": "%m | upper to %b1 | upper %b2 %b3 | lower"
}
# Current branch: some/CoMpLEX-123-5/BRANCH
$ git commit -m "added a thing"
$ git log -1 --pretty=%B
# Output: ADDED A THING to SOME CoMpLEX-123-5 branch
$ yarn install
$ yarn test[:unit|:integration|:e2e|:smoke]
$ yarn build
FAQs
A git commit-msg hook that automatically inserts a matched pattern from the active branch name to the commit message.
The npm package branch-commit-msg receives a total of 14 weekly downloads. As such, branch-commit-msg popularity was classified as not popular.
We found that branch-commit-msg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.