Miss any of our Open RFC calls?Watch the recordings here! »

validate-branch-name

1.0.6 • Public • Published

validate-branch-name

中文文档

English Document

GitHub license npm version Build Status codecov PRs Welcome Known Vulnerabilities npm download

Git branch name validator through hooks.

Description

validate-branch-name is based on Husky, so make sure that your repository have installed husky (version >= v1.0.0) successfully.

Install

$ npm i validate-branch-name --save-dev

Usage

Configure hooks and pattern using package.json.

"validate-branch-name" attribute in package.json is optional, we have set default pattern and errorMsg in project. But you can still defined them as you like.

// {app_root}/package.json
{
  "husky": {
    "hooks": {
      "pre-push": "validate-branch-name"
    }
  },
  "validate-branch-name": {
    "pattern": "^(master|develop){1}$|^(feature|fix|hotfix|release)\/.+$",
    "errorMsg": "your own error message"
  }
}

Default pattern: ^(master|develop){1}$|^(feature|fix|hotfix|release)/.+$

Example: feature/test/pattern-test would be passed.

Avaliable patterns:

  • ^(feature|fix|hotfix|release)/.+ - branch has to start with feature/, fix/, release/ or hotfix/
  • (feature|release|hotfix)/(JIRA-\d+) - it should look like feature/JIRA-1234
  • (feature|release|hotfix)/(JIRA-\d+/)?[a-z-]+ - it should look like feature/branch-name or include JIRA's code like feature/JIRA-1234/branch-name

You can also configure hooks and pattern using .validate-branch-namerc, .validate-branch-namerc.json or .validate-branch-namerc.js file.

Requirements

  1. Husky requires Node >= 8.6.0 and Git >= 2.13.2
  2. Husky version >= 1.0.0

Questions & Suggestions

Please open an issue here.

License

MIT

Install

npm i validate-branch-name

DownloadsWeekly Downloads

920

Version

1.0.6

License

MIT

Unpacked Size

14.3 kB

Total Files

15

Last publish

Collaborators

  • avatar