Skip to content

Commit ac69338

Browse files
committed
feat(post): add commit messages convention
1 parent d36d180 commit ac69338

File tree

4 files changed

+182
-0
lines changed

4 files changed

+182
-0
lines changed

.mdl.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
rule 'MD013', :line_length => 130
44

5+
rule 'MD007', :indent => 4
6+
57
exclude_rule 'MD002'
8+
exclude_rule 'MD040'
69
exclude_rule 'MD041'
710

_posts/2023-03-01-commit-messages.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
---
2+
layout: post
3+
title: "Commit message convention"
4+
author: vitor
5+
categories: [ team, bahamut, github, agreement ]
6+
image: assets/images/commit-message-convention.png
7+
description: "A document describing our commit message convention that our tech team used across projects."
8+
featured: false
9+
hidden: false
10+
---
11+
Our tech team agreement on commit message conventions.
12+
13+
# Introduction
14+
15+
Good commit messages are important for maintaining projects and is the best way to
16+
communicate context about changes to other developers. Besides that, it will help us
17+
keep track of all commits and know exactly what changes were made in each commit.
18+
19+
This proposal aims to add more semantic meaning and create an understandable, readable,
20+
useful, and structured git commit history.
21+
22+
In the near future will help us with:
23+
24+
- Automatic changelog generation
25+
- Determine semantic version bump
26+
- Releases notes for the project
27+
28+
In this proposal we will follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
29+
It is a specification that provides easy rules for creating an explicit commit history which makes it easy
30+
for humans and machines to understand.
31+
32+
# Commit Message
33+
34+
```
35+
<type>[(optional scope)]: <description>
36+
37+
[optional body]
38+
39+
[optional footer(s)]
40+
```
41+
42+
## Type
43+
44+
- Communicate the intent of changes
45+
- Any case may be used, the important is to be consistent
46+
- Since one of the goals is a readable git history maybe we might use the capitalized one
47+
- **Lowercase**
48+
- Most general **&lt;type&gt;** values:
49+
- `feat:` A **new feature**
50+
- Eg:
51+
- `feat(state): add new state properties`
52+
- `fix:` A **bug fix**
53+
- Eg:
54+
55+
```
56+
fix(timeDimension): disable previous and next arrows (Monthly)
57+
58+
Disable previous and next month arrows when there is no more month composites
59+
```
60+
61+
- `refactor:` Changes related with **codebase modifying**, which **neither fixes a bug** nor
62+
**adds a feature** (Eg: renaming variable, improving functionalities, removing redundant code, simplifying the code, etc)
63+
- Eg:
64+
- `refactor(mini-maps): update rendering behavior`
65+
- `refactor(menu-selection): area selection behavior upgraded`
66+
- Other **&lt;type&gt;** values:
67+
- `chore:` Changes related to the **build system** (involving scripts, configurations or tools),
68+
**package dependencies** (eg: change to .gitignore file or .prettierrc file).
69+
- In **special cases**, could be used for **codebase styling** (Eg: indentations, quotes, trailing commas,
70+
missing semi colons, white-space, formatting, etc)
71+
- Eg:
72+
- `chore(npm): update axios to 0.17.1`
73+
- `chore(docs-infra): upgrade webpack to 3.2.4`
74+
- `chore(report): fix indentation in report component`
75+
- `ci:` Changes related to the **continuous integration** and **deployment** system - involving scripts, configurations or tools
76+
- Eg:
77+
- `ci(aws): unset default aws profile for CI deployment`
78+
- `docs:` Changes related to the **project documentation**
79+
- Eg:
80+
- `docs(change-log): update change log to RC.3`
81+
- `test:` Adding missing tests or correcting existing tests
82+
- Eg:
83+
- `test(tsl-map): add test for tsl-map component`
84+
85+
## Optional scope
86+
87+
- Provide additional contextual information
88+
- Should be nouns and surrounded by parentheses
89+
- Should always be lowercase
90+
- Case style:
91+
- **kebab-case**
92+
- By adding an exclamation `!` **** mark before the colon `:` is possible understand if the commit has any breaking changes
93+
- Eg: `refactor(vue)!: drop support for vue 2`
94+
95+
## Description
96+
97+
- Short message that describes what the commit does
98+
- It should be written in the imperative, present tense (&quot;_change&quot;_ not &quot;_changed&quot;_ nor &quot;_changes&quot;_)
99+
- Don&#39;t capitalize the first letter
100+
101+
The first commit line **can&#39;t** be longer than **70 characters**.
102+
103+
Eg: in the image below you can see:
104+
105+
**1 -** The more info button is due to added _optional body_.
106+
107+
**2 &amp; 3 -** The **maximum character limit** (**70**) was exceeded and the sentence was cut off.
108+
109+
![examples](/assets/images/commit-message-example.png)
110+
111+
## Optional body
112+
113+
- Used to explain what changes were made and why was made
114+
- Not all commits are complex enough to need a body
115+
116+
Each body line should be wrapped between **80 characters** maximum.
117+
118+
## Optional footer
119+
120+
- Should contain any information about **Breaking Changes**
121+
- **Breaking Changes** should start with the word `BREAKING CHANGE:` with a space. The rest of the commit message
122+
is then used for this.
123+
- All **Breaking Changes** have to be mentioned in footer with the description of the change and justification notes.
124+
- Place to reference GitHub issues that this commit **Closes,** mainly used when using an issue tracker to reference the issue ID
125+
- Can also be used for other metadata options
126+
127+
---
128+
129+
Any line of the commit message cannot be longer than **80 characters**! This allows the message to be **easier** **to read** on GitHub.
130+
131+
---
132+
133+
## Samples
134+
135+
### Simple commit messages
136+
137+
```
138+
feat(config): allow provided config object to extend other configs
139+
```
140+
141+
```
142+
docs(change-log): update changelog to beta.5
143+
```
144+
145+
```
146+
fix(router): update api endpoint
147+
```
148+
149+
### Commit message with body
150+
151+
```
152+
fix(release): need to depend on latest rxjs and zone.js
153+
154+
The version in our package.json gets copied to the one we publish, and users
155+
need the latest of these.
156+
```
157+
158+
```
159+
fix(middleware): ensure Range headers adhere more closely to RFC 2616
160+
161+
Add one new dependency, use `range-parser` (Express dependency) to compute
162+
range. It is more well-tested in the wild.
163+
164+
Closes #2310
165+
```
166+
167+
### Commit message with Breaking Change
168+
169+
```
170+
refactor!: drop support for Node 6
171+
```
172+
173+
```
174+
refactor(runtime)!: drop support for Node 6
175+
176+
BREAKING CHANGE: refactor to use JavaScript features not available in Node 6.
177+
```
178+
179+
It is possible to find other examples in: [**Conventional commit samples**](https://www.conventionalcommits.org/en/v1.0.0/#examples).
31 KB
Loading
56.1 KB
Loading

0 commit comments

Comments
 (0)