成果预览:

最终commit格局:

feat(Controller): 批改xxxxx

1. 概述

每次提交,Commit message 都包含三个局部:Header,Body 和 Footer。

<type>(<scope>): <subject>
// 空一行
<body>
// 空一行
<footer>

其中,Header 是必须的,Body 和 Footer 能够省略。
不论是哪一个局部,任何一行都不得超过72个字符(或100个字符)。这是为了防止主动换行影响好看。

2.1 Header

Header局部只有一行,包含三个字段:type(必须)、scope(可选)和subject(必须)。
(1)type
type用于阐明 commit 的类别,只容许应用上面7个标识。

1. feat:新性能(feature)
2. fix:修补bug
3. docs:文档(documentation)
4. style: 格局(不影响代码运行的变动)
5. refactor:重构(即不是新增性能,也不是批改bug的代码变动)
6. test:减少测试
7. chore:构建过程或辅助工具的变动

如果type为feat和fix,则该 commit 将必定呈现在 Change log 之中。其余状况(docs、chore、style、refactor、test)由你决定,要不要放入 Change log,倡议是不要。
(2)scope
scope用于阐明 commit 影响的范畴,比方数据层、管制层、视图层等等,视我的项目不同而不同。
(3)subject
subject是 commit 目标的简短形容,不超过50个字符。

  1. 以动词结尾,应用第一人称当初时,比方change,而不是changed或changes
  2. 第一个字母小写
  3. 结尾不加句号(.)

    2.2 Body

    Body 局部是对本次 commit 的详细描述,能够分成多行。上面是一个范例。

More detailed explanatory text, if necessary.  Wrap it to about 72 characters or so. Further paragraphs come after blank lines.- Bullet points are okay, too- Use a hanging indent

有两个留神点。
(1)应用第一人称当初时,比方应用change而不是changed或changes。
(2)应该阐明代码变动的动机,以及与以前行为的比照。
2.3 Footer
Footer 局部只用于两种状况。
(1)不兼容变动
如果以后代码与上一个版本不兼容,则 Footer 局部以BREAKING CHANGE结尾,前面是对变动的形容、以及变动理由和迁徙办法。

BREAKING CHANGE: isolate scope bindings definition has changed.    To migrate the code follow the example below:    Before:    scope: {      myAttr: 'attribute',    }    After:    scope: {      myAttr: '@',    }    The removed `inject` wasn't generaly useful for directives so there should be no code using it.

(2)敞开 Issue

如果以后 commit 针对某个issue,那么能够在 Footer 局部敞开这个 issue 。

Closes #234

也能够一次敞开多个 issue 。

Closes #123, #245, #992

2.4 Revert
还有一种非凡状况,如果以后 commit 用于撤销以前的 commit,则必须以revert:结尾,前面跟着被撤销 Commit 的 Header。

revert: feat(pencil): add 'graphiteWidth' optionThis reverts commit 667ecc1654a317a13331b17617d973392f415f02.

Body局部的格局是固定的,必须写成This reverts commit <hash>.,其中的hash是被撤销 commit 的 SHA 标识符。
如果以后 commit 与被撤销的 commit,在同一个公布(release)外面,那么它们都不会呈现在 Change log 外面。如果两者在不同的公布,那么以后 commit,会呈现在 Change log 的Reverts小标题上面。