Skip to content

Commit 1301c29

Browse files
authored
docs: Update commit message guidelines (#1175)
Also adds commitlint checks to verify the guidelines. JIRA: CPOUI5FOUNDATION-1152
1 parent 935b292 commit 1301c29

File tree

7 files changed

+1006
-35
lines changed

7 files changed

+1006
-35
lines changed

.github/workflows/commitlint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Commit Message Linting
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
commitlint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0
21+
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run lint:commit -- --edit "$1" # Lint currently edited commit message

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
[![OpenUI5 Community Slack (#tooling channel)](https://img.shields.io/badge/slack-join-44cc11.svg)](https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com)
99
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
1010

11+
This repository contains the current **development state** of the upcoming UI5 CLI v5 release.
12+
Note that previous versions (up to v4) are maintained in [dedicated repositories](https://github.com/UI5/cli/tree/v4?tab=readme-ov-file#modules).
13+
1114
> [UI5 CLI v4](https://ui5.github.io/cli/v4) is the latest and stable version 🎉
1215
>
1316
> [UI5 CLI v3](https://ui5.github.io/cli/v3) is a stable version and in maintenance mode 🚢

commitlint.config.mjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
export default {
2+
extends: [
3+
"@commitlint/config-conventional",
4+
],
5+
rules: {
6+
"type-enum": [
7+
2,
8+
"always",
9+
[
10+
"build",
11+
"ci",
12+
"deps",
13+
"docs",
14+
"feat",
15+
"fix",
16+
"perf",
17+
"refactor",
18+
"release",
19+
"revert",
20+
"style",
21+
"test",
22+
],
23+
],
24+
"body-max-line-length": [2, "always", 160],
25+
"footer-max-line-length": [0],
26+
"subject-case": [
27+
2, "always",
28+
["sentence-case", "start-case", "pascal-case"],
29+
],
30+
// Limit scope to package names and special cases
31+
"scope-enum": [
32+
2,
33+
"always",
34+
[
35+
// Package names
36+
"builder",
37+
"cli",
38+
"documentation",
39+
"fs",
40+
"logger",
41+
"project",
42+
"server",
43+
// Special scope for dev dependencies
44+
"deps-dev"
45+
]
46+
],
47+
"scope-case": [2, "always", "lowercase"],
48+
},
49+
ignores: [
50+
// Ignore release commits, as their subject doesn't start with an uppercase letter
51+
(message) => message.startsWith("release: v"),
52+
],
53+
};

docs/Guidelines.md

Lines changed: 76 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,97 @@ You may also find an ESLint integration for your favorite IDE [here](https://esl
66
## Testing
77
Unit testing is based on the [ava](https://github.com/avajs/ava) test-framework. You can run all tests using `npm test` (this is what our CI will do for all pull requests).
88

9-
During development, you might want to use `npm run unit` or `npm run unit-watch` (re-runs tests automatically after file changes) to quickly execute all unit tests and see whether your change just broke one of them. 😉
9+
During development, you might want to use `npm run unit` or `npm run unit-watch` (re-runs tests automatically after file changes; only available within a specific package) to quickly execute all unit tests and see whether your change just broke one of them. 😉
1010

1111
## Git Guidelines
1212
### No Merge Commits
1313
Please use [rebase instead of merge](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) to update a branch to the latest main. This helps keeping a clean commit history in the project.
1414

1515
### Commit Message Style
16-
#### Commit Summary
17-
The commit summary is the first line of the commit message.
1816

19-
- It should be **50-70 characters** long.
20-
- It must be **prefixed** by `[FIX]`, `[FEATURE]` or `[INTERNAL]` accordingly, followed by the name of the component or module which was the main subject of the change.
21-
+ Use `[FIX]` for bugfixes.
22-
+ Use `[FEATURE]` for new features / enhancements.
23-
+ Use `[BREAKING]` for breaking / incompatible changes.
24-
_**Note:** The commit body of a breaking change should also include a paragraph starting with `BREAKING CHANGE:`.
25-
This paragraph will be highlighted in the changelog._
26-
+ Use `[DEPENDENCY]` for dependency updates that should be mentioned in the changelog.
27-
+ Use `[INTERNAL]` for all other changes (e.g. refactorings, documentation, etc.). These changes will not be listed in the changelog.
28-
+ Exceptions are changes created by automated processes like releases or dependency updates
29-
- It must not contain `[` or `]` anywhere but in the prefix.
30-
- It shall be written in **imperative present tense** (as recommended by [Git](https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project))
31-
+ Examples: Instead of *"Adding tests for"* or *"I added tests for"* use *"Add tests for"* or *"Add feature xy"*.
17+
This project uses the [Conventional Commits specification](https://www.conventionalcommits.org/) to ensure a consistent way of dealing with commit messages.
3218

33-
#### Commit Body
34-
After the commit summary there should be an empty line followed by the commit body.
19+
#### Structure
3520

36-
- Describe the intention and reasoning of the change
37-
- If a change fixes an issue reported on GitHub, add the following line to the commit message:
38-
+ `Fixes: #<issueNumber>` (e.g. `Fixes: #42`)
39-
- Breaking changes should include a paragraph starting with `BREAKING CHANGE:`. This paragraph will be highlighted in the changelog.
21+
```
22+
type(scope): Description
23+
```
24+
25+
- **Type (required)**: Every commit message must start with a lowercase `type`. The project has defined a set of [valid types](../commitlint.config.mjs#L10)
26+
- **Scope (conditional)**: Required only for types that appear in the public changelog: `feat`, `fix`, `perf`, `deps`, and `revert`. The scope must be the package folder name (e.g. `cli`, `builder`, `fs`, `logger`, `project`, `server`, `documentation`). No other scopes are allowed (except `build(deps-dev)` for dev dependencies).
27+
- **Description (required)**: Must follow Sentence Case style. Only the first word and proper nouns are written in uppercase.
28+
29+
#### Dependencies
30+
31+
- Use `deps(scope)` for productive dependency updates that are relevant for end users
32+
- Use `build(deps-dev)` for development dependency updates
33+
34+
#### Breaking Changes
35+
36+
Breaking changes should follow the [Conventional Commits specification](https://www.conventionalcommits.org/):
37+
- Add `!` after the type/scope: `feat(cli)!: Remove deprecated command`
38+
- Include `BREAKING CHANGE:` in the commit footer with details about the change
4039

41-
#### Example
40+
#### Commitlint Rules
41+
42+
The following rules are enforced by commitlint:
43+
- Valid commit types are enforced (see [commitlint.config.mjs](../commitlint.config.mjs))
44+
- When using a scope, it must be one of: package names (`builder`, `cli`, `documentation`, `fs`, `logger`, `project`, `server`) or `deps-dev` for development dependencies
45+
- Commit messages must follow sentence case for the description
46+
47+
**Important**: Commitlint cannot automatically enforce that scopes are required only for public changelog types. Please manually ensure that:
48+
- `feat`, `fix`, `perf`, `deps`, `revert` commits always include a package scope
49+
- Other commit types should not include a scope (except `build(deps-dev)` for dev dependencies)
50+
51+
#### Examples
52+
53+
**Features and fixes:**
54+
```
55+
feat(cli): Add "versions" command
56+
fix(fs): Correctly handle paths containing non-ASCII characters on Windows
57+
perf(builder): Improve bundle generation speed by 25%
4258
```
43-
[FIX] npm translator: Correct handling of devDependencies
4459

45-
- devDevependencies should only be included in certain cases
46-
- Was caused by a refactoring
60+
**Dependencies:**
61+
```
62+
deps(cli): Update @ui5/logger to v4.0.0
63+
build(deps-dev): Update eslint to v9.0.0
64+
```
65+
66+
**Breaking changes:**
67+
```
68+
feat(cli)!: Remove deprecated "init" command
4769
48-
Fixes: #42
49-
Fixes: #45
70+
BREAKING CHANGE: The "init" command has been removed. Use "create" instead.
71+
```
72+
73+
**Workspace-wide changes (no scope):**
74+
```
75+
ci: Update GitHub Actions to use Node.js 20
76+
docs: Update contribution guidelines
77+
build: Configure new linting rules
5078
```
5179

52-
## Work on Release Branches
53-
Major releases are typically prepared on dedicated branches like `next`.
80+
### Multi-Package Changes
5481

55-
There are some things to be aware of when working on these branches.
82+
When making changes that affect multiple packages, create individual commits for each package to maintain clear scoping and changelog generation. Each commit should follow the conventional commit format with the appropriate package scope.
5683

57-
### Implementing Changes in Multiple Code Lines
58-
While working on a new major release (e.g. `5.0.0`), any fixes or new features implemented on the **current** (main) code line (e.g. 4.x) should be cherry-picked as `[INTERNAL]` to the dedicated (pre-)release branch (typically `next`). This is to prevent changes declared as `[FEATURE]` or `[FIX]` from appearing in the changelog twice, which can be confusing since the new major version has not yet been released and should naturally contain any fixes or features released in any of the preceding releases. Listing them twice might confuse users. Note that our changelog is generated based on all tags of the repository, independent of the currently checked out branch (also see [git-chglog/issues/123](https://github.com/git-chglog/git-chglog/issues/123)).
84+
**Exception:** Create a single commit for cross-package changes that do not affect the public changelog, such as:
85+
- Code style updates and formatting changes
86+
- Refactoring that doesn't change public APIs
87+
- Internal tooling and configuration updates
88+
- Documentation updates across packages
5989

60-
However, once a new major release becomes **current** (i.e. "main", not a pre-release), any changes applied to multiple code lines should be cherry picked with the original prefix, so that they appear for multiple versions in the changelog.
90+
#### Examples
91+
92+
For a feature spanning multiple packages:
93+
```
94+
feat(cli): Add support for new build option
95+
feat(builder): Implement new build option processing
96+
feat(fs): Add helper methods for new build option
97+
```
98+
99+
For refactoring across packages:
100+
```
101+
refactor: Standardize error handling across packages
102+
```

0 commit comments

Comments
 (0)