Genluo / Precipitation-and-Summary

梳理体系化的知识点&沉淀日常开发和学习
MIT License
16 stars 1 forks source link

1️⃣ GIT message 规范 #77

Open Genluo opened 4 years ago

Genluo commented 4 years ago

git message规范整理

Commit Message规范

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

1. 标题行

type的类型为:

2. 主题内容

描述为什么修改,做了什么样的修改,以及开发思路相关

3. 页脚注释

一些备注, 通常是 BREAKING CHANGE 或修复的 bug 的链接

4. 实例

实例

规范化

1. 设置git commit 模板

通过 git commit 进入多行编辑模式

[commit]
template = ~/.gitmessage
# head: <type>(<scope>): <subject>
# - type: feat, fix, docs, style, refactor, test, chore
# - scope: can be empty (eg. if the change is a global or difficult to assign to a single component)
# - subject: start with verb (such as 'change'), 50-character line
#
# body: 72-character wrapped. This should answer:
# * Why was this change necessary?
# * How does it address the problem?
# * Are there any side effects?
#
# footer: 
# - Include a link to the ticket, if any.
# - BREAKING CHANGE
#
git config --global commit.template ~/.gitmessage

2. 使用工具进行规范化提交

安装步骤:

npm install -g commitizen cz-conventional-changelog
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc

使用:

git cz

详情参见: https://juejin.im/post/5afc5242f265da0b7f44bee4

3. 配置强制进行检查,不通过,不予提交

npm i -D @commitlint/config-conventional @commitlint/cli

echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js

  "bin": {
       "commitlint": "./node_modules/@commitlint/cli/lib/cli.js"
  }

npm install husky --save-dev

{
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }  
  }
}

参考文档

Genluo commented 4 years ago

配置全局.gitignore文件 issue地址:https://github.com/alibaba/rax/pull/1633