Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6c49485

Browse files
committed
docs: how to create custom bumps
1 parent ddd220a commit 6c49485

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# CHANGELOG
22

3+
## v1.2.0
4+
5+
### Feature
6+
- custom cz plugins now support bumping version
7+
8+
## v1.1.1
9+
10+
### Fix
11+
- breaking change is now part of the body, instead of being in the subject
312

413
## v1.1.0
514

‎docs/bump.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,9 @@ files = [
122122
]
123123
```
124124

125+
## Custom bump
126+
127+
Read the [customizing section](./customization.md).
128+
125129
[pep440]: https://www.python.org/dev/peps/pep-0440/
126-
[semver]: https://semver.org/
130+
[semver]: https://semver.org/

‎docs/customization.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Customizing commitizen is not hard at all.
2+
3+
The basic steps are:
4+
5+
1. Inheriting from `BaseCommitizen`
6+
2. Give a name to your rules.
7+
3. expose the class at the end of your file assigning it to `discover_this`
8+
4. Create a python package starting with `cz_` using `setup.py`, `poetry`, etc
9+
10+
11+
Check an [example](convcomms) on how to configure `BaseCommitizen`.
12+
113
## Custom commit rules
214

315
Create a file starting with `cz_` for example `cz_jira.py`. This prefix
@@ -83,3 +95,35 @@ doing `pip install .`
8395
If you feel like it should be part of this repo, create a PR.
8496

8597
[flask uses]: http://flask.pocoo.org/docs/0.12/extensiondev/
98+
99+
## Custom bump rules
100+
101+
You need to define 2 parameters inside `BaseCommitizen`.
102+
103+
| Parameter | Type | Default | Description |
104+
| --------- | ---- | ------- | ----------- |
105+
| `bump_pattern` | `str` | `None` | Regex to extract information from commit (subject and body) |
106+
| `bump_map` | `dict` | `None` | Dictionary mapping the extracted information to a `SemVer` increment type (`MAJOR`, `MINOR`, `PATCH`) |
107+
108+
Let's see an exampple
109+
110+
```python
111+
from commitizen.cz.base import BaseCommitizen
112+
113+
114+
class StrangeCommitizen(BaseCommitizen):
115+
bump_pattern = r"^(break|new|fix|hotfix)"
116+
bump_map = {"break": "MAJOR", "new": "MINOR"}
117+
```
118+
119+
As you can see we have ommitted `fix` and `hotfix`, both are gonna be picked up
120+
by the regex, but because they are not present in `bump_map` they will be mapped
121+
by default to `PATCH`
122+
123+
That's it, your commitizen now supports custom rules and you can run
124+
125+
```bash
126+
cz -n cz_strange bump
127+
```
128+
129+
[convcomms]: https://github.com/Woile/commitizen/blob/master/commitizen/cz/conventional_commits/conventional_commits.py

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /