Skip to content

Commit 6bd086c

Browse files
committed
Deploying to gh-pages from @ 048fa47 🚀
1 parent 96f4221 commit 6bd086c

52 files changed

Lines changed: 9542 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

commands/bump/index.md

Lines changed: 546 additions & 0 deletions
Large diffs are not rendered by default.

commands/changelog/index.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
## About
2+
3+
Generates a changelog following the committing rules established.
4+
5+
When changelog generation is triggered by `cz bump --allow-no-commit` (with `--changelog` or `update_changelog_on_bump = true`), Commitizen still creates a release entry even when no commits are found in the selected revision range.
6+
7+
Tip
8+
9+
To create the changelog automatically on bump, add the setting [update_changelog_on_bump](https://commitizen-tools.github.io/commitizen/config/bump/#update_changelog_on_bump)
10+
11+
```
12+
[tool.commitizen]
13+
update_changelog_on_bump = true
14+
```
15+
16+
## Usage
17+
18+
## Examples
19+
20+
```
21+
# Generate full changelog
22+
cz changelog
23+
24+
# Or use the alias
25+
cz ch
26+
27+
# Get the changelog for the given version
28+
cz changelog 0.3.0 --dry-run
29+
30+
# Get the changelog for the given version range
31+
cz changelog 0.3.0..0.4.0 --dry-run
32+
```
33+
34+
## Constraints
35+
36+
Changelog generation is constrained only to **markdown** files.
37+
38+
## Description
39+
40+
These are the variables used by the changelog generator.
41+
42+
```
43+
# <version> (<date>)
44+
45+
## <change_type>
46+
47+
- **<scope>**: <message>
48+
```
49+
50+
Creates a full block like above per version found in the tags, and a list of the commits found. The `change_type` and `scope` are optional and don't need to be provided, but if your regex parses them, they will be rendered.
51+
52+
The format followed by the changelog is from [keep a changelog](https://keepachangelog.com/) and the following variables are expected:
53+
54+
| Variable | Description | Source |
55+
| ------------- | ---------------------------------------------------------------------------------------------- | -------------- |
56+
| `version` | Version number which should follow [semver](https://semver.org/) | `tags` |
57+
| `date` | Date when the tag was created | `tags` |
58+
| `change_type` | The group where the commit belongs to, this is optional. Example: fix | `commit regex` |
59+
| `message` | Information extracted from the commit message | `commit regex` |
60+
| `scope` | Contextual information. Should be parsed using the regex from the message, it will be **bold** | `commit regex` |
61+
| `breaking` | Whether it is a breaking change or not | `commit regex` |
62+
63+
Note
64+
65+
`message` is the only variable required to be parsed by the regex.
66+
67+
## Command line options
68+
69+
### `--extras`
70+
71+
Provide your own changelog extra variables by using the `extras` settings or the `--extra/-e` parameter.
72+
73+
```
74+
cz changelog --extra key=value -e short="quoted value"
75+
```
76+
77+
### `--file-name`
78+
79+
Specify the name of the output file. Note that changelog generation only works with Markdown files.
80+
81+
```
82+
cz changelog --file-name="CHANGES.md"
83+
```
84+
85+
This value can be updated in the configuration file with the key `changelog_file` under `tool.commitizen`.
86+
87+
```
88+
[tool.commitizen]
89+
# ...
90+
changelog_file = "CHANGES.md"
91+
```
92+
93+
### `--incremental`
94+
95+
Build from the latest version found in changelog.
96+
97+
Benefits:
98+
99+
- Useful if you have an existing changelog and want to use commitizen to extend it.
100+
- Update unreleased area
101+
- Allows users to manually edit the changelog without it being completely rewritten.
102+
103+
```
104+
cz changelog --incremental
105+
```
106+
107+
This flag can be set in the configuration file with the key `changelog_incremental` under `tool.commitizen`.
108+
109+
```
110+
[tool.commitizen]
111+
# ...
112+
changelog_incremental = true
113+
```
114+
115+
### `--start-rev`
116+
117+
Start from a given git rev to generate the changelog. Commits before that rev will not be considered. This is especially useful for long-running projects adopting conventional commits, where old commit messages might fail to be parsed for changelog generation.
118+
119+
```
120+
cz changelog --start-rev="v0.2.0"
121+
```
122+
123+
This value can be set in the configuration file with the key `changelog_start_rev` under `tool.commitizen`
124+
125+
```
126+
[tool.commitizen]
127+
# ...
128+
changelog_start_rev = "v0.2.0"
129+
```
130+
131+
### `--merge-prerelease`
132+
133+
Collects changes from prereleases into the next non-prerelease version. If you have a prerelease version followed by a normal release, the changelog will show the prerelease changes as part of the normal release. If not set, prereleases will be included as separate entries in the changelog.
134+
135+
```
136+
cz changelog --merge-prerelease
137+
```
138+
139+
This flag can be set in the configuration file with the key `changelog_merge_prerelease` under `tool.commitizen`
140+
141+
```
142+
[tool.commitizen]
143+
# ...
144+
changelog_merge_prerelease = true
145+
```
146+
147+
### `--template`
148+
149+
Provide your own changelog Jinja template by using the `template` settings or the `--template` parameter.
150+
151+
```
152+
cz changelog --template="path/to/template.j2"
153+
```
154+
155+
### `--unreleased-version`
156+
157+
There is usually a chicken-and-egg situation when automatically bumping the version and creating the changelog:
158+
159+
- If you bump the version first, you have no changelog yet, and it won't be included in the release of the created version.
160+
- If you create the changelog before bumping the version, you usually don't have the latest tag, and the *Unreleased* title appears.
161+
162+
By using `--unreleased-version`, you can prevent this situation.
163+
164+
Before bumping you can run:
165+
166+
```
167+
cz changelog --unreleased-version="v1.0.0"
168+
```
169+
170+
Remember to use the tag format instead of the raw version number.
171+
172+
For example, if your tag format includes a `v` prefix (e.g., `v1.0.0`), use that format. If your tag is the same as the raw version (e.g., `1.0.0`), use the raw version.
173+
174+
Alternatively, you can directly bump the version and create the changelog by running:
175+
176+
```
177+
cz bump --changelog
178+
```
179+
180+
## Hooks
181+
182+
Supported hook methods:
183+
184+
- Per parsed message: Useful to add links to commits or issues
185+
- End of changelog generation: Useful to send Slack or chat messages, or notify another department
186+
187+
Read more about hooks in the [customization page](https://commitizen-tools.github.io/commitizen/customization/config_file/index.md)

commands/check/index.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
This feature checks whether a string or a range of git commits follows the given committing rules. Comments in git messages will be ignored.
2+
3+
To set up an automatic check before every git commit, please refer to [Automatically check message before commit](https://commitizen-tools.github.io/commitizen/tutorials/auto_check/index.md).
4+
5+
## Usage
6+
7+
More specifically, there are three mutually exclusive ways to use `cz check`:
8+
9+
- Validate a range of git commit messages with `--rev-range`
10+
- Validate a given string with `--message` or by piping the message to it
11+
- Validate a commit message from a file with `--commit-msg-file`
12+
13+
### Use `cz check` to validate a commit message before committing
14+
15+
#### Option 1: use `--message` to check a given string:
16+
17+
```
18+
cz check --message <message_to_be_checked>
19+
```
20+
21+
#### Option 2: pipe the message to `cz check`:
22+
23+
```
24+
echo <message_to_be_checked> | cz check
25+
```
26+
27+
#### Option 3: use `--commit-msg-file` to read the commit message from a file
28+
29+
```
30+
cz check --commit-msg-file /path/to/file.txt
31+
```
32+
33+
## Command Line Options
34+
35+
### `--rev-range`
36+
37+
Test if a given range of commits in the git log passes `cz check`.
38+
39+
```
40+
cz check --rev-range REV_RANGE
41+
```
42+
43+
For more information on `REV_RANGE`, check the [git documentation](https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#_commit_ranges).
44+
45+
#### Use cases
46+
47+
1. Validate the latest 3 commit messages:
48+
49+
```
50+
cz check --rev-range HEAD~3..HEAD
51+
# or
52+
cz check --rev-range HEAD~3..
53+
# or
54+
cz check --rev-range HEAD~~~..
55+
```
56+
57+
1. Validate all git commit messages on some branch up to HEAD:
58+
59+
```
60+
cz check --rev-range <branch_name>..HEAD
61+
```
62+
63+
For example, to check all git commit messages on `main` branch up to HEAD:
64+
65+
```
66+
cz check --rev-range main..HEAD
67+
```
68+
69+
or if your project still uses `master` branch:
70+
71+
```
72+
cz check --rev-range master..HEAD
73+
```
74+
75+
Default branch
76+
77+
Usually the default branch is `main` or `master`. You can check the default branch by running `cz check --use-default-range`.
78+
79+
1. Validate all git commit messages starting from when you first implemented commit message linting:
80+
81+
**(Why this is useful?)** Let's say you decided to enforce commit message today. However, it is impractical to `git rebase` all your previous commits. `--rev-range` helps you skip commits before you first implemented commit message linting by using a specific commit hash.
82+
83+
```
84+
cz check --rev-range <first_commit_sha>..HEAD
85+
```
86+
87+
### `--use-default-range`
88+
89+
Equivalent to `--rev-range <default_branch>..HEAD`.
90+
91+
```
92+
cz check --use-default-range
93+
# or
94+
cz check -d
95+
```
96+
97+
### `--message`
98+
99+
Test if a given string passes `cz check`.
100+
101+
```
102+
cz check --message <message_to_be_checked>
103+
```
104+
105+
### `--commit-msg-file`
106+
107+
Test if a given file contains a commit message that passes `cz check`.
108+
109+
```
110+
cz check --commit-msg-file <path_to_file_containing_message_to_be_checked>
111+
```
112+
113+
This can be useful when cooperating with git hooks. Please check [Automatically check message before commit](https://commitizen-tools.github.io/commitizen/tutorials/auto_check/index.md) for more detailed examples.
114+
115+
### `--allow-abort`
116+
117+
Example:
118+
119+
```
120+
cz check --message <message_to_be_checked> --allow-abort
121+
```
122+
123+
Empty commit messages typically instruct Git to abort a commit, so you can pass `--allow-abort` to permit them. Since `git commit` accepts the `--allow-empty-message` flag (primarily for wrapper scripts), you may wish to disallow such commits in CI. `--allow-abort` may be used in conjunction with any of the other options.
124+
125+
### `--allowed-prefixes`
126+
127+
Skip validation for commit messages that start with the specified prefixes.
128+
129+
If not set, commit messages starting with the following prefixes are ignored by `cz check`:
130+
131+
- `Merge`
132+
- `Revert`
133+
- `Pull request`
134+
- `fixup!`
135+
- `squash!`
136+
- `amend!`
137+
138+
```
139+
cz check --message <message_to_be_checked> --allowed-prefixes 'Merge' 'Revert' 'Custom Prefix'
140+
```
141+
142+
For example,
143+
144+
```
145+
# The following message passes the check because it starts with 'Merge'
146+
cz check --message "Merge branch 'main' into feature/new-feature" --allowed-prefixes 'Merge'
147+
148+
# The following fails
149+
cz check --message "Merge branch 'main' into feature/new-feature" --allowed-prefixes 'aaa'
150+
```
151+
152+
### `--message-length-limit`
153+
154+
Restrict the length of **the first line** of the commit message.
155+
156+
```
157+
# The following passes
158+
cz check --message "docs(check): fix grammar issues" -l 80
159+
160+
# The following fails
161+
cz check --message "docs:very long long long long message with many words" -l 3
162+
```
163+
164+
By default, the limit is set to `0`, which means no limit on the length.
165+
166+
Note
167+
168+
Specifically, for `ConventionalCommitsCz` the length only counts from the type of change to the subject, while the body and the footer are not counted.

0 commit comments

Comments
 (0)