Gathering detailed insights and metrics for @stinobe/git-tools
Gathering detailed insights and metrics for @stinobe/git-tools
A tool to help validate commit messages before committing & branch names before pushing them.
npm install @stinobe/git-tools
Typescript
Module System
Node Version
NPM Version
71.5
Supply Chain
98.8
Quality
75.2
Maintenance
100
Vulnerability
99.5
License
TypeScript (88.37%)
JavaScript (11.63%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
666
Last Day
1
Last Week
3
Last Month
22
Last Year
214
2 Stars
35 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Feb 28, 2023
Latest Version
1.0.2
Package Id
@stinobe/git-tools@1.0.2
Unpacked Size
20.45 kB
Size
5.31 kB
File Count
18
NPM Version
8.3.0
Node Version
16.13.0
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-40%
3
Compared to previous week
Last Month
214.3%
22
Compared to previous month
Last Year
31.3%
214
Compared to previous year
A tool to help validate commit messages before committing & branch names before pushing them.
The tool will not run in CI thanks to ci-info
To be used with Husky
1npm install @stinobe/git-tools
Assuming you haven't installed and/or configured Husky.
Add precommit
and prepublish
scripts in package.json
1# Set script for commits 2npm set-script precommit "stinobe-commit-message" 3 4# Set script for branches 5npm set-script prepush "stinobe-branch-name"
If Husky not yet installed
1# Install Husky 2npm install husky --save-dev 3 4# Enable Git hook 5npx husky install 6 7# Automatically enable Git hooks after install 8npm set-script prepare "husky install"
Add previously created NPM scripts to Husky
1# Inform Husky of pre commit script 2npx husky add .husky/pre-commit "npm run precommit" 3 4# Inform Husky of pre publish script 5npx husky add .husky/pre-publish "npm run prepublish"
A default configuration is built in, but you can overwrite those by a .gittoolrc
, .gittool.json
or by adding a gittool
property in the package.json
file (in order of hierarchy).
Configuration exists of Commit message configuration and Branch name configuration.
1{ 2 "commits": [], 3 "branches": {} 4}
All settings are optional
Commit settings exists of an array containing differenc configuration for different branch names
Property | Type | Description |
---|---|---|
branches | RegExp | Regex to check if rules apply on current branch |
validation | RegExp | Regex where commit message will be tested against |
examples | string[] | Will be printed out in the console when validation fails |
How the default commit message settings look like
1{ 2 "commits": [ 3 { 4 "branches": /.*/, 5 "validation": /([Cc]lose[sd]?|[Ff]ix(e[sd])?|[Rr]esolve[sd]?) #[1-9]+\d*/, 6 "examples": [ 7 "Commit message contains one of:", 8 "\tclose #[issue-number]", 9 "\tcloses #[issue-number]", 10 "\tclosed #[issue-number]", 11 "\tfix #[issue-number]", 12 "\tfixes #[issue-number]", 13 "\tfixed #[issue-number]", 14 "\tresolve #[issue-number]", 15 "\tresolves #[issue-number]", 16 "\tresolved #[issue-number]" 17 ] 18 } 19 ], 20 "branches": {} 21}
branches
property can be an empty string or be left out but will cause a log in the output.
Property | Type | Description |
---|---|---|
validation | RegExp[] | List of regular expressions with allowed branch names |
examples | string[] | List of example branch names, will be logged if validation fails |
How the default branch name settings look like
1{ 2 "commit": [], 3 "branches": { 4 "validation": [ 5 /^(feature|bug|docs|hotfix)\/(\d+)-[a-z-]+/, 6 /^wip\/[a-z1-9]+[a-z0-9]*/ 7 ], 8 "examples": [ 9 "feature/[issue_number]-[subject]", 10 "bug/[issue_number]-[subject]", 11 "docs/[issue_number]-[subject]", 12 "hotfix/[issue_number]-[subject]" 13 ] 14 } 15}
No vulnerabilities found.
No security vulnerabilities found.