Checks whether current Git branch is protected
$ npm install git-is-branch-protected
const gitIsBranchProtected = require('git-is-branch-protected')
(async () => {
// currently on "master" branch
await gitIsBranchProtected()
//=> true
await gitIsBranchProtected('master')
//=> true
await gitIsBranchProtected('develop')
//=> true
await gitIsBranchProtected('feat/add-something')
//=> false
await gitIsBranchProtected('develop', ['master'])
//=> false
await gitIsBranchProtected('develop', ['master, develop'])
//=> true
await gitIsBranchProtected('DEVELOP', ['master, develop'], { caseSensitive: true })
//=> false
})()
Returns true
or false
indicating whether a branch is protected.
Type: string
The name of the current branch. Defaults to check the actual branch name of the current directory.
Type: Array
Default: ['master', 'develop']
Which branches you would like to protect. By default, master
and develop
are protected.
Type: Object
Type: boolean
Default: false
Whether the check should be performed case sensitive.
- git-is-branch-protected-cli - CLI for this project.
- git-push-pr - Push and open pull request in your default browser.
MIT © Tobias Büschel