目標
- 允許 git bisect 忽略 commit (不重要的 commit,例如格式設定)
- 瀏覽歷史記錄時提供更佳的資訊
警告
此規則適用於所有 Quasar 儲存庫。
良好維護的日誌非常美觀且實用。 git blame
、revert
、rebase
、log
、shortlog
和其他子命令都變得生動起來。審閱他人的 commit 和 pull request 成為值得做的事情,而且突然間可以獨立完成。了解幾個月或幾年前發生某事的原因不僅變得可能,而且效率更高。
良好 Git Commit 訊息的規則
- 用空行分隔主旨和內文
- 將主旨行限制為 70 個字元
- 主旨行開頭字母大寫
- 主旨行末尾不要加句點
- 在主旨行中使用祈使語氣
- 將內文換行至 80 個字元
- 在內文中使用說明「什麼」和「為什麼」,而不是「如何」
Commit 訊息的格式
type(<scope>): <Subject> #<github-ref-id>
<body>
<footer>
content_paste
Commit 訊息範例
fix(ui): Ensure Range headers adhere more closely to RFC 2616 #2310
To add new dependency use `range-parser`to compute the range.
It is more well-tested in the wild.
BREAKING CHANGE:
port-runner command line option has changed to runner-port.
To migrate your project, change all the commands,
where you use --port-runner to --runner-port.
content_paste
訊息主旨 (第一行)
第一行不能超過 70 個字元,第二行永遠是空白行。類型和範圍應始終為小寫,如下所示。
允許的 <type>
值
- feat - 使用者的新功能,而不是建置腳本的新功能
- fix - 使用者的錯誤修正,而不是建置腳本的修正
- docs - 僅文檔變更
- style - 不影響程式碼含義的變更 (空格、格式設定、遺漏分號等)
- refactor - 重構生產程式碼,既不修正錯誤也不新增功能的程式碼變更
- chore - 其他不修改 src 或測試檔案的變更 (無生產程式碼變更) 和依賴項更新
- perf - 改善效能的變更
- revert - 還原先前的 commit
- test - 新增遺漏的測試、重構測試;無生產程式碼變更
- build - 影響建置系統或外部依賴項的變更 (例如 ui/build/*)
- ci - 對我們的持續整合組態檔案和腳本的變更 (例如 GitHub Actions)
範例 <scope>
值
- 目錄/套件相關:ui、cli、app-webpack、app-vite 等。
- 功能相關:api、TouchSwipe、QTime 等。
提示
可以包含更多以 &
符號分隔的值。範例:feat(app-vite&app-webpack): Add Capacitor mode
。
可以為空 (例如,如果變更是全域性的),在這種情況下,括號會被省略。範例:style: Use semicolons
訊息內文
- 使用祈使語氣、現在時態:「change」而不是「changed」或「changes」
- 包括變更的動機,並與先前的行為形成對比
訊息頁尾
重大變更
所有重大變更都必須在頁尾的重大變更區塊中提及,該區塊應以單字 BREAKING CHANGE: 開頭,後跟一個空格或兩個換行符。commit 訊息的其餘部分則是變更的描述、理由和遷移注意事項。
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
}
content_paste
參考議題
已關閉的議題應在頁尾的單獨一行中列出,並以「Closes」關鍵字作為前綴,如下所示
Closes #234
或者在多個議題的情況下
Closes #123, #245, #992