zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Git Conventional Commits (Git代码提交说明规范)

2023-03-07 09:38:09 时间

Conventional Commits (代码提交说明规范)

Conventional Commits 是关于Git Commit 提交代码时, 填写的说明文字的一个规范. 这个规范提供了一套易于理解和使用的规则, 通过描述提交消息中的特性, 修复和重大更改, 创建易于阅读的提交历史, 也方便在其之上编写自动化工具.

提交时的消息格式应该按如下格式组织:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

例子

feat: add hat wobble
^--^  ^------------^
|     |
|     +-> 简单的描述
|
+-------> 类型: chore, docs, feat, fix, refactor, style, or test.

前缀说明

各种前缀的使用场景:

  • feat: 面向用户的功能的新特性, 不包括项目构建的新特性
  • fix: bug修复
  • docs: 任何文档相关的修改
  • style: 格式方面的改动, 不涉及代码逻辑的改动
  • refactor: 重构类型的修改, 例如修改一个变量名
  • test: 测试代码相关的改动, 例如增加测试案例, 重构测试代码等
  • chore: 日常工作, 例如更新组件版本号, 发布版本, 打标签等

例子

Commit message with description and breaking change footer

feat: allow provided config object to extend other configs

BREAKING CHANGE: `extends` key in config file is now used for extending other config files

Commit message with ! to draw attention to breaking change

feat!: send an email to the customer when a product is shipped

Commit message with scope and ! to draw attention to breaking change

feat(api)!: send an email to the customer when a product is shipped

Commit message with both ! and BREAKING CHANGE footer

chore!: drop support for Node 6

BREAKING CHANGE: use JavaScript features not available in Node 6.

Commit message with no body

docs: correct spelling of CHANGELOG

Commit message with scope

feat(lang): add Polish language

参考