1.0.0 • Published 5 years ago

git-is-branch-protected v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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