約定式提交
約定式提交規(guī)范是一種基于提交消息的輕量級(jí)約定。它提供了一組用于創(chuàng)建清晰的提交歷史的簡(jiǎn)單規(guī)則合愈;這使得編寫(xiě)基于規(guī)范的自動(dòng)化工具變得更容易。
feat: allow provided config object to extend other configs
約定式提交的格式
<類(lèi)型>[可選的作用域]: <描述>
[可選的正文]
[可選的腳注]
Header (<類(lèi)型>[可選的作用域]: <描述>)??
header包含三部分內(nèi)容: type(必需),scope(可選)和subject(必需)
type
用于說(shuō)明commit的類(lèi)型浙巫,常見(jiàn)的類(lèi)型有:
feat: 新功能
fix: 修補(bǔ)bug
docs: 文檔的變更
style: 格式(不影響代碼運(yùn)行的變動(dòng))
refactor: 重構(gòu)(即不是新增功能雇逞,也不是修改bug的代碼變動(dòng))
perf: 用于性能改進(jìn)的代碼提交
test: 用于添加或修改現(xiàn)有測(cè)試
build: 修改影響到了系統(tǒng)的構(gòu)建或外部依賴
ci: 修改CI配置文件或相關(guān)的腳本
revert: 用于撤銷(xiāo)以前的commit
chore: 其他一些不影響源碼或測(cè)試文件的代碼變動(dòng)
scope
用于說(shuō)明commit影響的范圍,比如數(shù)據(jù)層,控制層,視圖層等等度秘。
subject
commit目的的簡(jiǎn)短描述顶伞,不超過(guò)50個(gè)字符饵撑。
Body(
[可選的正文]
)
Body 部分是對(duì)本次commit的詳細(xì)描述,可以分成多行唆貌,如
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
填寫(xiě)要求:使用第一人稱現(xiàn)在時(shí)滑潘,比如使用change而不是changed或changes。應(yīng)該說(shuō)明代碼變動(dòng)的動(dòng)機(jī)锨咙,以及與以前行為的對(duì)比语卤。
Footer(
[可選的腳注]
)
Footer部分只用于兩種情況
不兼容變動(dòng)
如果當(dāng)前代碼與上一個(gè)版本不兼容,則Footer部分以BREAKING CHANGE開(kāi)頭,后面是對(duì)變動(dòng)的描述酪刀,以及變動(dòng)理由和遷移方法粹舵。如:
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.
關(guān)閉Issue
Closes #234
Closes #123, #245, #992
示例
// 包含了描述以及正文內(nèi)有破壞性變更的提交說(shuō)明
feat: allow provided config object to extend other configs
BREAKING CHANGE: `extends` key in config file is now used for extending other config files// 包含了可選的 ! 字符以提醒注意破壞性變更的提交說(shuō)明
chore!: drop Node 6 from testing matrix
BREAKING CHANGE: dropping Node 6 which hits end of life in April// 不包含正文的提交說(shuō)明
docs: correct spelling of CHANGELOG// 包含作用域的提交說(shuō)明
feat(lang): add polish language// 為 fix 編寫(xiě)的提交說(shuō)明,包含(可選的) issue 編號(hào)
fix: correct minor typos in code
see the issue for details on the typos fixed
closes issue #12
工具
使用commitizen
需提前安裝nodejs(官網(wǎng)下載地址)
git cz
安裝步驟:
全局安裝commitizen node 模塊
npm install -g commitizen
在項(xiàng)目目錄下運(yùn)行
npm init --yes
如果是node項(xiàng)目,可直接運(yùn)行
commitizen init cz-conventional-changelog --save --save-exact
運(yùn)行完以上步驟就可以使用git cz 替代 git commit 來(lái)提交代碼骂倘,同時(shí)會(huì)顯示選項(xiàng)來(lái)自動(dòng)生成符合格式的commit message.
git-cz
npm install -g commitizen git-cz
使用Git Commit Message Helper
安裝方式
idea -> settings -> plugins -> 搜索Git Commit Message Helper
使用方式
提交時(shí)打開(kāi)idea commit(ctrl+k)
點(diǎn)擊上圖紅框標(biāo)識(shí)部位,會(huì)出現(xiàn)如下彈框,之后便可以在該彈框中填寫(xiě)具體的commit信息眼滤。