enforce-gitflow-branches
v1.0.8
Published
Enforces Git branch names according to the Git Flow branching model
Downloads
3,569
Readme
Enforces Git branch names according to the Git Flow branching model.
Usage:
$ yarn add -D enforce-gitflow-branches husky@next
or
$ npm install --save-dev enforce-gitflow-branches husky@next
Then set up Husky and set a hook:
"husky": {
"hooks": {
"pre-push": "enforce-gitflow-branches"
}
}
This script checks the current branch name and exits the Node process with exit code 0 if it is valid (see source). If the branch name is invalid it exits with exit code 1, which causes Husky to prevent the action from completing.
To write custom controls create a file with:
// enforce.js
const enforce = require('enforce-gitflow-branches')
enforce()
// ...other tests
To add custom branch names in your custom controls, use node-current-branch to access the current branch name.
Finally set up Husky and set a hook:
"husky": {
"hooks": {
"pre-push": "node enforce.js"
}
}