git 提交規範強制檢查

公司採用的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"
      …
    }
  }
  …
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章