Skip to content

Commit 8f1b2cb

Browse files
authored
Merge pull request #390 from commitizen-tools/fix/357-release-candidate
fix(changelog): generating changelog after a pre-release
2 parents 0d44d24 + d82727c commit 8f1b2cb

6 files changed

+155
-1
lines changed

commitizen/defaults.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
change_type_order = ["BREAKING CHANGE", "feat", "fix", "refactor", "perf"]
4444

4545
commit_parser = r"^(?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)?:\s(?P<message>.*)?" # noqa
46-
version_parser = r"(?P<version>([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?)"
46+
version_parser = r"(?P<version>([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?(\w+)?)"

docs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Supported versions](https://img.shields.io/pypi/pyversions/commitizen.svg?style=flat-square)](https://pypi.org/project/commitizen/)
66
[![homebrew](https://img.shields.io/homebrew/v/commitizen?color=teal&style=flat-square)](https://formulae.brew.sh/formula/commitizen)
77
[![Codecov](https://img.shields.io/codecov/c/github/commitizen-tools/commitizen.svg?style=flat-square)](https://codecov.io/gh/commitizen-tools/commitizen)
8+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?style=flat-square&logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
89

910
![Using commitizen cli](images/demo.gif)
1011

tests/commands/test_changelog_command.py

+33
Original file line numberDiff line numberDiff line change
@@ -480,3 +480,36 @@ def test_changelog_incremental_keep_a_changelog_sample_with_annotated_tag(
480480
out = f.read()
481481

482482
file_regression.check(out, extension=".md")
483+
484+
485+
@pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"])
486+
@pytest.mark.usefixtures("tmp_commitizen_project")
487+
def test_changelog_incremental_with_release_candidate_version(
488+
mocker, capsys, changelog_path, file_regression, test_input
489+
):
490+
"""Fix #357"""
491+
with open(changelog_path, "w") as f:
492+
f.write(KEEP_A_CHANGELOG)
493+
create_file_and_commit("irrelevant commit")
494+
git.tag("1.0.0", annotated=True)
495+
496+
create_file_and_commit("feat: add new output")
497+
create_file_and_commit("fix: output glitch")
498+
499+
testargs = ["cz", "bump", "--changelog", "--prerelease", test_input, "--yes"]
500+
mocker.patch.object(sys, "argv", testargs)
501+
cli.main()
502+
503+
create_file_and_commit("fix: mama gotta work")
504+
create_file_and_commit("feat: add more stuff")
505+
create_file_and_commit("Merge into master")
506+
507+
testargs = ["cz", "changelog", "--incremental"]
508+
509+
mocker.patch.object(sys, "argv", testargs)
510+
cli.main()
511+
512+
with open(changelog_path, "r") as f:
513+
out = f.read()
514+
515+
file_regression.check(out, extension=".md")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## Unreleased
8+
9+
### Feat
10+
11+
- add more stuff
12+
13+
### Fix
14+
15+
- mama gotta work
16+
17+
## 0.2.0a0 (2021-06-11)
18+
19+
### Fix
20+
21+
- output glitch
22+
23+
### Feat
24+
25+
- add new output
26+
27+
## [1.0.0] - 2017-06-20
28+
### Added
29+
- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
30+
- Version navigation.
31+
32+
### Changed
33+
- Start using "changelog" over "change log" since it's the common usage.
34+
35+
### Removed
36+
- Section about "changelog" vs "CHANGELOG".
37+
38+
## [0.3.0] - 2015-12-03
39+
### Added
40+
- RU translation from [@aishek](https://github.com/aishek).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## Unreleased
8+
9+
### Feat
10+
11+
- add more stuff
12+
13+
### Fix
14+
15+
- mama gotta work
16+
17+
## 0.2.0b0 (2021-06-11)
18+
19+
### Fix
20+
21+
- output glitch
22+
23+
### Feat
24+
25+
- add new output
26+
27+
## [1.0.0] - 2017-06-20
28+
### Added
29+
- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
30+
- Version navigation.
31+
32+
### Changed
33+
- Start using "changelog" over "change log" since it's the common usage.
34+
35+
### Removed
36+
- Section about "changelog" vs "CHANGELOG".
37+
38+
## [0.3.0] - 2015-12-03
39+
### Added
40+
- RU translation from [@aishek](https://github.com/aishek).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## Unreleased
8+
9+
### Feat
10+
11+
- add more stuff
12+
13+
### Fix
14+
15+
- mama gotta work
16+
17+
## 0.2.0rc0 (2021-06-11)
18+
19+
### Fix
20+
21+
- output glitch
22+
23+
### Feat
24+
25+
- add new output
26+
27+
## [1.0.0] - 2017-06-20
28+
### Added
29+
- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
30+
- Version navigation.
31+
32+
### Changed
33+
- Start using "changelog" over "change log" since it's the common usage.
34+
35+
### Removed
36+
- Section about "changelog" vs "CHANGELOG".
37+
38+
## [0.3.0] - 2015-12-03
39+
### Added
40+
- RU translation from [@aishek](https://github.com/aishek).

0 commit comments

Comments
 (0)