AngularJS Git 提交消息规范
目标
- 脚本化生成 CHANGELOG.md
- 识别不重要的提交
- 在浏览历史记录时提供更多信息
提交消息的格式
提交消息由标题、正文和脚注组成,各部分之间用一个空行隔开。
<type>(<scope>): <subject><body><footer>
提交消息的任何一行都不能超过 100 个字符!这使得消息在 GitHub 和各种 Git 工具中更容易阅读。
Revert (回滚)
如果提交是回滚之前的提交,其标题应以 revert:
开头,后跟被回滚提交的标题。在正文中,应写明:This reverts commit <hash>.
,其中 hash
是被回滚提交的 SHA 值。
消息标题
消息标题是单行,包含对更改的简洁描述,包括类型、可选范围和主题。
允许的 <type>
这描述了此提交提供的更改类型:
- feat (新功能)
- fix (bug 修复)
- docs (文档)
- style (格式化,缺少分号等)
- refactor (重构)
- test (添加缺失的测试)
- chore (维护)
允许的 <scope>
范围可以是指定提交更改位置的任何内容。例如:$location
、$browser
、$compile
、$rootScope
、ngHref
、ngClick
、ngView
等。
如果没有更合适的范围,可以使用 *
。
<subject>
文本
这是对更改的非常简短的描述。
- 使用祈使句,现在时态:“change”而不是“changed”或“changes”
- 首字母不要大写
- 末尾没有点号 (.)
消息正文
与 <subject>
一样,使用祈使句,现在时态:“change”而不是“changed”或“changes”。
包括更改的动机以及与先前行为的对比。
- http://365git.tumblr.com/post/3308646748/writing-git-commit-messages
- http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
消息脚注
Breaking changes (破坏性更改)
所有破坏性更改都必须在脚注中作为破坏性更改块提及,该块应以“BREAKING CHANGE:”开头,后跟一个空格或两个换行符。提交消息的其余部分是对更改的描述、理由和迁移说明。
BREAKING CHANGE: isolate scope bindings definition has changed andthe inject option for the directive controller injection was removed.To migrate the code follow the example below:Before:scope: {myAttr: 'attribute',myBind: 'bind',myExpression: 'expression',myEval: 'evaluate',myAccessor: 'accessor'}After:scope: {myAttr: '@',myBind: '@',myExpression: '&',// myEval - usually not useful, but in cases where the expression is assignable, you can use '='myAccessor: '=' // in directive's template change myAccessor() to myAccessor}The removed `inject` wasn't generaly useful for directives so there should be no code using it.
Referencing issues (引用问题)
已关闭的 bug 应在脚注中单独列出,并以“Closes”关键字作为前缀,如下所示:
Closes #234
或者在涉及多个问题时:
Closes #123, #245, #992
示例
feat($browser): onUrlChange event (popstate/hashchange/polling)Added new event to $browser:
- forward popstate event if available
- forward hashchange event if popstate not available
- do polling when neither popstate nor hashchange availableBreaks $browser.onHashChange, which was removed (use onUrlChange instead)
fix($compile): couple of unit tests for IE9Older IEs serialize html uppercased, but IE9 does not...
Would be better to expect case insensitive, unfortunately jasmine does
not allow to user regexps for throw expectations.Closes #392
Breaks foo.bar api, foo.baz should be used instead
feat(directive): ng:disabled, ng:checked, ng:multiple, ng:readonly, ng:selectedNew directives for proper binding these attributes in older browsers (IE).
Added coresponding description, live examples and e2e tests.Closes #351
style($location): add couple of missing semi colons
docs(guide): updated fixed docs from Google DocsCouple of typos fixed:
- indentation
- batchLogbatchLog -> batchLog
- start periodic checking
- missing brace
feat($compile): simplify isolate scope bindingsChanged the isolate scope binding options to:- @attr - attribute binding (including interpolation)- =model - by-directional model binding- &expr - expression execution bindingThis change simplifies the terminology as well as
number of choices available to the developer. It
also supports local name aliasing from the parent.BREAKING CHANGE: isolate scope bindings definition has changed and
the inject option for the directive controller injection was removed.To migrate the code follow the example below:Before:scope: {myAttr: 'attribute',myBind: 'bind',myExpression: 'expression',myEval: 'evaluate',myAccessor: 'accessor'
}After:scope: {myAttr: '@',myBind: '@',myExpression: '&',// myEval - usually not useful, but in cases where the expression is assignable, you can use '='myAccessor: '=' // in directive's template change myAccessor() to myAccessor
}The removed `inject` wasn't generaly useful for directives so there should be no code using it.