Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tobiasbueschel/git-is-branch-protected
🔒Checks whether current Git branch is protected
https://github.com/tobiasbueschel/git-is-branch-protected
bitbucket branch conventional git git-flow github gitlab
Last synced: 10 days ago
JSON representation
🔒Checks whether current Git branch is protected
- Host: GitHub
- URL: https://github.com/tobiasbueschel/git-is-branch-protected
- Owner: tobiasbueschel
- License: mit
- Created: 2019-04-28T10:47:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T17:56:37.000Z (over 4 years ago)
- Last Synced: 2024-11-29T13:56:22.799Z (27 days ago)
- Topics: bitbucket, branch, conventional, git, git-flow, github, gitlab
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: license
Awesome Lists containing this project
README
# git-is-branch-protected
[![Build Status](https://img.shields.io/travis/tobiasbueschel/git-is-branch-protected/master.svg?style=flat-square)](https://travis-ci.com/tobiasbueschel/git-is-branch-protected)
[![version](https://img.shields.io/npm/v/git-is-branch-protected.svg?style=flat-square)](http://npm.im/git-is-branch-protected)
[![downloads](https://img.shields.io/npm/dm/git-is-branch-protected.svg?style=flat-square)](http://npm-stat.com/charts.html?package=git-is-branch-protected)
[![codecov](https://img.shields.io/codecov/c/github/tobiasbueschel/git-is-branch-protected.svg?style=flat-square)](https://codecov.io/gh/tobiasbueschel/git-is-branch-protected?branch=master)[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![MIT License](https://img.shields.io/npm/l/git-is-branch-protected.svg?style=flat-square)](http://opensource.org/licenses/MIT)> Checks whether current Git branch is protected
## Install
```
$ npm install git-is-branch-protected
```## Usage
```js
const gitIsBranchProtected = require('git-is-branch-protected')(async () => {
// currently on "master" branch
await gitIsBranchProtected()
//=> trueawait gitIsBranchProtected('master')
//=> trueawait gitIsBranchProtected('develop')
//=> trueawait gitIsBranchProtected('feat/add-something')
//=> falseawait gitIsBranchProtected('develop', ['master'])
//=> falseawait gitIsBranchProtected('develop', ['master, develop'])
//=> trueawait 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.
## Related
- [git-is-branch-protected-cli](https://github.com/tobiasbueschel/git-is-branch-protected-cli) - CLI for this project.
- [git-push-pr](https://github.com/tobiasbueschel/git-push-pr) - Push and open pull request in your default browser.## License
MIT © [Tobias Büschel](https://github.com/tobiasbueschel)