git-提交规范强制检查

4次阅读

共计 695 个字符,预计需要花费 2 分钟才能阅读完成。

公司采用的 commit 规范

<type>: 描述 

type

用于说明 commit 的类别,只允许使用下面标识:

  • feat:新功能(feature)
  • fix:修补 bug
  • docs:文档(documentation)
  • style:格式(不影响代码运行的变动)
  • refactor:重构(即不是新增功能,也不是修改 bug 的代码变动)
  • perf:优化

git 提交信息进行强制检查

npm install --save-dev validate-commit-msg

然后,添加文件.vcmrc

{"types": ["feat", "fix", "docs", "style", "refactor", "perf"],
  "scope": {
    "required": false,
    "allowed": ["*"],
    "validate": false,
    "multiple": false
  },
  "warnOnFail": false,
  "maxSubjectLength": 100,
  "subjectPattern": ".+",
  "subjectPatternErrorMsg": "subject does not match subject pattern!",
  "helpMessage": "","autoFix": false
}

ghooks

npm install ghooks --save-dev

https://www.npmjs.com/package/ghooks
Add a config.ghooks entry in your package.json,配置暂时只需要:

{
  …
  "config": {
    "ghooks": {
      "commit-msg": "validate-commit-msg"
      …
    }
  }
  …
}

正文完
 0