File tree Expand file tree Collapse file tree 1 file changed +102
-0
lines changed Expand file tree Collapse file tree 1 file changed +102
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Commit 规范
2
+
3
+ 在对项目作出更改后,我们需要生成 Commit 来记录自己的更改。以下是参照 Angular 对 Commit 格式的规范:
4
+
5
+ ## (1) 格式
6
+
7
+ 提交信息包括三个部分:` Header ` ,` Body ` 和 ` Footer ` 。
8
+
9
+ ```
10
+ <Header>
11
+
12
+ <Body>
13
+
14
+ <Footer>
15
+ ```
16
+
17
+ 其中,Header 是必需的,Body 和 Footer 可以省略。
18
+
19
+ #### 1> Header
20
+
21
+ Header 部分只有一行,包括俩个字段:` type ` (必需)和` subject ` (必需)。
22
+
23
+ ```
24
+ <type>: <subject>
25
+ ```
26
+
27
+ ** Type**
28
+
29
+ Type 用于说明 Commit 的类别,可以使用如下类别:
30
+
31
+ - feat:新功能(Feature)
32
+ - fix:修补 Bug
33
+ - doc:文档(Documentation)
34
+ - style: 格式(不影响代码运行的变动)
35
+ - refactor:重构(即不是新增功能,也不是修改 Bug 的代码变动)
36
+ - test:增加测试
37
+ - chore:构建过程或辅助工具的变动
38
+
39
+ ** Subject**
40
+
41
+ Subject 是 Commit 目的的简短描述。
42
+
43
+ - 以动词开头,使用第一人称现在时,比如改变,而不是改变了。
44
+ - 结尾不加句号(。)
45
+
46
+ #### 2> Body
47
+
48
+ Body 部分是对本次 Commit 的详细描述,可以分成多行。下面是一个范例。
49
+
50
+ ```
51
+ More detailed explanatory text, if necessary. Wrap it to
52
+ about 72 characters or so.
53
+
54
+ Further paragraphs come after blank lines.
55
+
56
+ - Bullet points are okay, too
57
+ - Use a hanging indent
58
+ ```
59
+
60
+ ** 注意:** 应该说明代码变动的动机,以及与以前行为的对比。
61
+
62
+ #### 3> Footer
63
+
64
+ Footer 部分应该包含:(1)Breaking Changes; (2)关闭 Issue;
65
+
66
+ ** Breaking Changes** :
67
+
68
+ 如果当前代码与上一个版本不兼容,则 Footer 部分以` BREAKING CHANGE ` 开头,后面是对变动的描述、以及变动理由和迁移方法。这种使用较少,了解即可。
69
+
70
+ ** Issue 部分:**
71
+
72
+ - 通过 Commit 关联 Issue:
73
+
74
+ 如果当前提交信息关联了某个 Issue,那么可以在 Footer 部分关联这个 Issue:
75
+
76
+ ```
77
+ issue #2
78
+ ```
79
+
80
+ - 通过 Commit 关闭 Issue,当提交到** 默认分支** 时,提交信息里可以使用 ` fix/fixes/fixed ` , ` close/closes/closed ` 或者 ` resolve/resolves/resolved ` 等关键词,后面再跟上 Issue 号,这样就会关闭这个 Issue:
81
+
82
+ ```
83
+ closes #1
84
+ ```
85
+
86
+ 注意,如果不是提交到默认分支,那么并不能关闭这个 Issue,但是在这个 Issue 下面会显示相关的信息表示曾经想要关闭这个 Issue,当这个分支合并到默认分支时,就可以关闭这个 Issue 了。
87
+
88
+ #### 4> 例子
89
+
90
+ 下面是一个完整的例子:
91
+
92
+ ```
93
+ feat: 添加了分享功能
94
+
95
+ 给每篇文章添加了分享功能
96
+
97
+ - 添加分享到微信功能
98
+ - 添加分享到朋友圈功能
99
+
100
+ issue #1, #2
101
+ closes #1
102
+ ```
You can’t perform that action at this time.
0 commit comments