git-is-branch-protected
v1.0.0
Published
Checks whether a Git branch is protected
Downloads
4
Readme
git-is-branch-protected
Checks whether current Git branch is protected
Install
$ npm install git-is-branch-protected
Usage
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
})()
API
gitIsBranchProtected([currentBranch], [protectedBranches], [options])
Returns true
or false
indicating whether a branch is protected.
currentBranch
Type: string
The name of the current branch. Defaults to check the actual branch name of the current directory.
protectedBranches
Type: Array
Default: ['master', 'develop']
Which branches you would like to protect. By default, master
and develop
are protected.
options
Type: Object
caseSensitive
Type: boolean
Default: false
Whether the check should be performed case sensitive.
License
MIT © Tobias Büschel