鏍煎紡鍖栦綘鐨刧it message
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鏍煎紡鍖栦綘鐨刧it message相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/semi' title='semi'>semi ali 涓夊眰 ocs 绌烘牸 document 杩佺Щ鏂规硶 width 鐩存帴
https://github.com/angular/angular.js/blob/f3377da6a748007c11fde090890ee58fae4cefa5/CONTRIBUTING.md#commit
Git Commit Guidelines
We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the AngularJS change log.
The commit message formatting can be added using a typical git workflow or through the use of a CLI wizard (Commitizen). To use the wizard, run npm run commit
in your terminal after staging your changes in git.
Commit Message Format
Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
The header is mandatory and the scope of the header is optional.
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.
Revert
If the commit reverts a previous commit, it should begin with revert:
, followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>.
, where the hash is the SHA of the commit being reverted.
Type
Must be one of the following:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
fix锛氫竴涓敊璇慨澶?/p>
docs锛氫粎鏂囨。鏇存敼
style锛氫笉褰卞搷浠g爜鍚箟鐨勬洿鏀癸紙绌烘牸锛屾牸寮忓寲锛岀己灏戝垎鍙风瓑锛?/p>
refactor锛氫唬鐮佹洿鏀规棦涓嶄慨澶嶄篃涓嶅鍔犲姛鑳?/p>
perf锛氭敼杩涙€ц兘鐨勪唬鐮佹洿鏀?/p>
test锛氭坊鍔犵己灏戠殑娴嬭瘯
chore锛氬鏋勫缓杩囩▼鎴栬緟鍔╁伐鍏峰拰搴擄紙濡傛枃妗g敓鎴愶級鐨勬洿鏀?/p>
revert锛氫唬鐮佸洖閫€
Scope
The scope could be anything specifying place of the commit change. For example $location
, $browser
, $compile
, $rootScope
, ngHref
, ngClick
, ngView
, etc...
Subject
The subject contains succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don鈥榯 capitalize first letter
- no dot (.) at the end
Body
Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
Footer
The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit Closes.
Breaking Changes should start with the word BREAKING CHANGE:
with a space or two newlines. The rest of the commit message is then used for this.
A detailed explanation can be found in this document.
鏍煎紡鍖栦綘鐨刧it message
1.1 缂樼敱
閲嶅缓涓€娈典唬鐮佺殑涓婁笅鏂囨槸涓€绉嶆氮璐广€傛垜浠笉鑳藉畬鍏ㄩ伩鍏嶏紝鎴戜滑鍙兘鍔姏灏芥渶澶у彲鑳藉幓鍑忓皯瀹冦€傛彁浜ょ殑淇℃伅灏卞彲浠ュ仛鍒拌繖涓€鐐癸紝浠ヨ嚦浜庝竴涓彁浜や俊鎭彲浠ヨ〃鏄庝竴涓紑鍙戣€呮槸涓嶆槸涓€涓ソ鐨勫悎浣滆€呫€?/p>
濡傛灉浣犲濡備綍鍐欏ソ git 鎻愪氦淇℃伅娌℃湁浠旂粏鎯宠繃锛岄偅浣犲緢鍙兘娌℃湁鎬庝箞浣跨敤杩?git log 鍜岀浉鍏冲伐鍏枫€傝繖閲屾湁涓€涓伓鎬у惊鐜細鍥犱负鎻愪氦鐨勫巻鍙蹭俊鎭粍缁囨贩涔辫€屼笖鍓嶅悗鐭涚浘锛岄偅鍚庨潰鐨勪汉涔熷氨涓嶆効鎰忚姳鏃堕棿鍘讳娇鐢ㄥ拰缁存姢瀹冦€?鍙堝洜涓烘病鏈変汉鍘讳娇鐢ㄥ拰缁存姢瀹冿紝鎻愪氦鐨勪俊鎭氨浼氫竴鐩寸粍缁囨贩涔卞拰鍓嶅悗鐭涚浘銆?/p>
1.2 浣滅敤
- 鎻愪緵鏇村鐨勫巻鍙蹭俊鎭紝鏂逛究蹇€熸祻瑙堛€?/li>
//涓嬮潰鐨勫懡浠ゆ樉绀轰笂娆″彂甯冨悗鐨勫彉鍔紝姣忎釜commit鍗犳嵁涓€琛屻€備綘鍙湅琛岄锛屽氨鐭ラ亾鏌愭 commit 鐨勭洰鐨勩€?
git log <last tag> HEAD --pretty=format:%s
- 鍙互杩囨护鏌愪簺commit锛堟瘮濡傛枃妗f敼鍔級锛屼究浜庡揩閫熸煡鎵句俊鎭€?/li>
- 鍙互鐩存帴浠巆ommit鐢熸垚Change log銆?/li>
1.2 鐩殑
缁熶竴鍥㈤槦git commit 鍥㈤槦鏃ュ織鏍囧噯锛屼究浜庡悗缁唬鐮乺eview鍜屽彂甯冪増鏈?/p>
2 瑙勮寖
鍩轰簬浣跨敤鏈€骞挎硾鐨?a href="https://link.jianshu.com?t=https%3A%2F%2Fdocs.google.com%2Fdocument%2Fd%2F1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y%2Fedit%23heading%3Dh.uyo6cb12dt6w" rel="nofollow" target="_blank">angular鏃ュ織瑙勮寖
銆?br />
鍒嗕负涓夐儴鍒嗭細鏍囬銆佸唴瀹广€佺粨灏撅紝鍏朵腑锛?=鏍囬==鏄?=蹇呴渶==鐨勶紝鍐呭鏃犻渶杩囧鎻忚堪鐨勮瘽锛屾鏂囧唴瀹归儴鍒嗗彲浠ョ渷鐣ャ€?/p>
涓嶇鏄摢涓€涓儴鍒嗭紝浠讳綍銆備竴琛岄兘涓嶅緱瓒呰繃72涓瓧绗︼紙鎴?00涓瓧绗︼級銆傝繖鏄负浜嗛伩鍏嶈嚜鍔ㄦ崲琛屽奖鍝嶇編瑙?/p>
<绫诲瀷>(鑼冨洿): <涓婚>
// 绌轰竴琛?
<鍐呭>
// 绌轰竴琛?
<Footer>
2.1 鏍囬
- 鏍囬閮ㄥ垎鍙湁涓€琛岋紝鍖呮嫭瀛楁锛氱被鍨?鍜?涓婚銆?/li>
- 鏍囬闄愬埗鎬诲瓧鏁板湪50涓瓧绗︿互鍐咃紝浠ヤ繚璇佸鏄撻槄璇汇€?/li>
feat: init LearnGit.git
I got a wrong-style git commit, so I init a .git for learning
how to write a git commit message in right way.
And the last line just write here for a simple test,
it鈥榮 useless acturally.
2.1.1 绫诲瀷
绫诲瀷鐢ㄤ簬璇存槑 commit 鐨勭被鍒紝鍙厑璁镐娇鐢ㄤ笅闈?涓爣璇嗐€?/p>
- init锛氶」鐩垵濮嬪寲锛堢敤浜庨」鐩垵濮嬪寲鎴栧叾浠栨煇绉嶈涓虹殑寮€濮嬫弿杩帮紝涓嶅奖鍝嶄唬鐮侊級
- feat锛氭柊鍔熻兘锛坒eature锛?/li>
- fix锛氫慨琛ug
- docs锛氭枃妗o紙documentation锛?/li>
- opt锛氫紭鍖栧拰鏀瑰杽锛屾瘮濡傚脊绐楄繘琛岀‘璁ゆ彁绀虹瓑鐩稿叧鐨勶紝涓嶄細鏀瑰姩閫昏緫鍜屽叿浣撳姛鑳界瓑
- style锛?鏍煎紡锛堜笉褰卞搷浠g爜杩愯鐨勫彉鍔級
- refactor锛氶噸鏋勶紙鍗充笉鏄柊澧炲姛鑳斤紝涔熶笉鏄慨鏀筨ug鐨勪唬鐮佸彉鍔級
- test锛氬鍔犳祴璇?/li>
- other锛氱敤浜庨毦浠ュ垎绫荤殑绫诲埆锛堜笉寤鸿浣跨敤锛屼絾涓€浜涘鍒犻櫎涓嶅繀瑕佺殑鏂囦欢锛屾洿鏂?ignore涔嬬被鐨勫彲浠ヤ娇鐢級
2.1.2 鑼冨洿
绫诲瀷鍚庨潰鍙互鍔犱笂鎷彿锛屾嫭鍙峰唴濉啓涓昏鍙樺姩鐨勮寖鍥达紝姣斿鎸夊姛鑳芥ā鍧楀垎锛屾煇妯″潡锛涙垨鎸夐」鐩笁灞傛灦鏋勬ā寮忓垎锛屽垎鏁版嵁灞傘€佹帶鍒跺眰涔嬬被鐨勩€?br /> #锛氳〃绀烘ā鍧?br /> - #market--> 琛ㄧず 鍟嗗煄妯″潡 锛堝叿浣撶殑妯″潡寮€澶村瓧姣嶅皬鍐欙紝椹煎嘲鍛藉悕锛?br /> - #ALL --> 琛ㄧず 鎵€鏈夋ā鍧?锛堢壒娈婂惈涔夊ALL琛ㄦ墍鏈夛紝MOST琛ㄥぇ閮ㄥ垎锛岀敤澶у啓瀛楁瘝琛ㄧず锛?br /> - #MOST --> 琛ㄧず 澶ч儴鍒嗘ā鍧?/p>
feat(#market): 鏂板娣诲晢鍩庡姛鑳?
2.1.3 涓婚
涓婚 鏄?commit 鐩殑鐨勭畝鐭弿杩帮紝涓嶈秴杩?0涓瓧绗︺€?/p>
- 绗竴涓瓧姣嶅皬鍐?/li>
- 浠ュ姩璇嶅紑澶?/li>
- 缁撳熬涓嶅姞鍙ュ彿
2.2 鍐呭
鍐呭閮ㄥ垎鏄鏈 commit 鐨勮缁嗘弿杩帮紝鍙互鍒嗘垚澶氳锛屾鏂囧湪 72 涓瓧绗﹀鎹㈣銆?/p>
浣跨敤姝f枃瑙i噴鏄粈涔?what)鍜屼负浠€涔?why)锛岃€屼笉鏄浣曞仛锛屼互鍙婁笌浠ュ墠琛屼负鐨勫姣斻€?/p>
2.3 Footer
Footer 閮ㄥ垎鍙敤浜庝袱绉嶆儏鍐碉細
-
涓嶅吋瀹瑰彉鍔?/p>
濡傛灉褰撳墠浠g爜涓庝笂涓€涓増鏈笉鍏煎锛屽垯 Footer 閮ㄥ垎浠REAKING
CHANGE寮€澶达紝鍚庨潰鏄鍙樺姩鐨勬弿杩般€佷互鍙婂彉鍔ㄧ悊鐢卞拰杩佺Щ鏂规硶銆?/p> -
鍏抽棴 Issue
濡傛灉褰撳墠 commit 閽堝鏌愪釜issue锛岄偅涔堝彲浠ュ湪 Footer 閮ㄥ垎鍏抽棴杩欎釜 issue 銆?/p>
Closes #123, #245, #992
2.4 Revert
杩樻湁涓€绉嶇壒娈婃儏鍐碉紝濡傛灉褰撳墠 commit 鐢ㄤ簬鎾ら攢浠ュ墠鐨?commit锛屽垯蹇呴』浠evert:寮€澶达紝鍚庨潰璺熺潃琚挙閿€ Commit 鐨?Header銆?/p>
revert: feat(pencil): add 鈥榞raphiteWidth鈥?option
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
Body閮ㄥ垎鐨勬牸寮忔槸鍥哄畾鐨勶紝蹇呴』鍐欐垚This reverts commit <hash>.锛屽叾涓殑hash鏄鎾ら攢 commit 鐨?SHA 鏍囪瘑绗︺€?/p>
3 宸ュ叿
3.1 Commitizen
Commitizen鏄竴涓牸寮忓寲commit message鐨勫伐鍏枫€傞€氳繃涓婇潰瀹夎濂界殑npm鏉ュ畨瑁咃細
npm install -g commitizen
鑰屾垜浠敤鐨勬槸Angular鐨刢ommit message瑙勮寖锛岄偅涔堝氨鍦ㄦ垜浠」鐩殑鐩綍涓嬭緭鍏ヤ互涓嬪懡浠わ細
commitizen init cz-conventional-changelog --save --save-exact
鐢熸垚package.json鏂囦欢锛屾湁鏃跺€欒繖涓枃浠跺悕浼氶敊璇紝闇€瑕佹墜鍔ㄤ慨鏀规枃浠跺悕銆傛垨鑰咃細
鍏堝湪椤圭洰涓坊鍔犱竴涓┖鐨刾ackage.json鏂囦欢锛岀劧鍚庡啀杈撳叆濮嬪寲閰嶇疆package.json鏂囦欢鍛戒护锛?/p>
npm init --yes
鐒跺悗杈撳叆锛?/p>
commitizen init cz-conventional-changelog --save --save-exact
鎺ヤ笅鏉ュ湪鎻愪氦鐨勬椂鍊欙紝灏辩敤git cz鏇挎崲git commit鍛戒护锛屼細鍑虹幇鎻愪氦绫诲瀷鐨勯€夋嫨锛岄€夋嫨鐩稿簲绫诲瀷灏卞ソ銆?/p>
3.2 鐢熸垚CHANGELOG
conventional-changelog灏辨槸鐢熸垚 Change log 鐨勫伐鍏枫€?/p>
杩愯涓嬪垪鍛戒护锛?/p>
$ npm install -g conventional-changelog
$ cd my-project
$ conventional-changelog -p angular -i CHANGELOG.md -w
濡傛灉鏈€鍚庡嚭鐜癱ommand not found锛屽氨瑕佹敼鐢╟onventional-changelog-cli锛?/p>
$ npm install -g conventional-changelog-cli
$ cd my-project
$ conventional-changelog -p angular -i CHANGELOG.md -s
閫氳繃浠ヤ笂鍛戒护浣犲氨浼氬彂鐜板湪椤圭洰涓浜嗕釜CHANGELOG.md鏂囦欢锛岃〃绀虹敓鎴?Change log鎴愬姛浜嗐€?/p>
以上是关于鏍煎紡鍖栦綘鐨刧it message的主要内容,如果未能解决你的问题,请参考以下文章