git-is-branch-protected

1.0.0 • Public • Published

git-is-branch-protected

Build Status version downloads codecov Greenkeeper badge semantic-release MIT License

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

/git-is-branch-protected/

    Package Sidebar

    Install

    npm i git-is-branch-protected

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    10.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • tobiasbueschel