Skip to content

Commit fb214be

Browse files
Merge branch 'master' into fix/bump-changelog-merge-pre-removes-header
2 parents 778edcb + 2cfb8c6 commit fb214be

39 files changed

+254
-164
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ repos:
5656
- tomli
5757

5858
- repo: https://github.com/commitizen-tools/commitizen
59-
rev: v4.13.4 # automatically updated by Commitizen
59+
rev: v4.13.5 # automatically updated by Commitizen
6060
hooks:
6161
- id: commitizen
6262
- id: commitizen-branch

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v4.13.5 (2026-02-05)
2+
3+
### Fix
4+
5+
- **changelog**: add incremental parameter to changelog generation (#1808)
6+
17
## v4.13.4 (2026-02-04)
28

39
### Fix

commitizen/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.13.4"
1+
__version__ = "4.13.5"

commitizen/commands/changelog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def __call__(self) -> None:
284284
self.cz.template_loader,
285285
self.template,
286286
**{
287+
"incremental": self.incremental, # extra variable for the template
287288
**self.cz.template_extras,
288289
**self.config.settings["extras"],
289290
**self.extras,

pyproject.toml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "commitizen"
3-
version = "4.13.4"
3+
version = "4.13.5"
44
description = "Python commitizen client tool"
55
authors = [{ name = "Santiago Fraire", email = "santiwilly@gmail.com" }]
66
maintainers = [
@@ -235,15 +235,7 @@ select = [
235235
"TC005",
236236
"TC006",
237237
]
238-
ignore = [
239-
"E501",
240-
"D1",
241-
"D415",
242-
"PT006", # TODO(bearomorphism): enable this rule
243-
"PT007", # TODO(bearomorphism): enable this rule
244-
"PT011", # TODO(bearomorphism): enable this rule
245-
"PT022", # TODO(bearomorphism): enable this rule
246-
]
238+
ignore = ["E501", "D1", "D415"]
247239
extend-safe-fixes = [
248240
"TC", # Move imports inside/outside TYPE_CHECKING blocks
249241
"UP", # Update syntaxes for current Python version recommendations

tests/commands/test_bump_command.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040

4141
@pytest.mark.parametrize(
4242
"commit_msg",
43-
(
43+
[
4444
"fix: username exception",
4545
"fix(user): username exception",
4646
"refactor: remove ini configuration support",
4747
"refactor(config): remove ini configuration support",
4848
"perf: update to use multiprocess",
4949
"perf(worker): update to use multiprocess",
50-
),
50+
],
5151
)
5252
@pytest.mark.usefixtures("tmp_commitizen_project")
5353
def test_bump_patch_increment(commit_msg: str, util: UtilFixture):
@@ -56,7 +56,7 @@ def test_bump_patch_increment(commit_msg: str, util: UtilFixture):
5656
assert git.tag_exist("0.1.1") is True
5757

5858

59-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
59+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
6060
@pytest.mark.usefixtures("tmp_commitizen_project")
6161
def test_bump_minor_increment(commit_msg: str, util: UtilFixture):
6262
util.create_file_and_commit(commit_msg)
@@ -68,7 +68,7 @@ def test_bump_minor_increment(commit_msg: str, util: UtilFixture):
6868
)
6969

7070

71-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
71+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
7272
@pytest.mark.usefixtures("tmp_commitizen_project")
7373
def test_bump_minor_increment_annotated(commit_msg: str, util: UtilFixture):
7474
util.create_file_and_commit(commit_msg)
@@ -82,7 +82,7 @@ def test_bump_minor_increment_annotated(commit_msg: str, util: UtilFixture):
8282
assert git.is_signed_tag("0.2.0") is False
8383

8484

85-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
85+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
8686
@pytest.mark.usefixtures("tmp_commitizen_project_with_gpg")
8787
def test_bump_minor_increment_signed(commit_msg: str, util: UtilFixture):
8888
util.create_file_and_commit(commit_msg)
@@ -96,7 +96,7 @@ def test_bump_minor_increment_signed(commit_msg: str, util: UtilFixture):
9696
assert git.is_signed_tag("0.2.0") is True
9797

9898

99-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
99+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
100100
def test_bump_minor_increment_annotated_config_file(
101101
commit_msg: str, util: UtilFixture, pyproject: Path
102102
):
@@ -112,7 +112,7 @@ def test_bump_minor_increment_annotated_config_file(
112112
assert git.is_signed_tag("0.2.0") is False
113113

114114

115-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
115+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
116116
def test_bump_minor_increment_signed_config_file(
117117
commit_msg: str, util: UtilFixture, tmp_commitizen_project_with_gpg
118118
):
@@ -132,7 +132,7 @@ def test_bump_minor_increment_signed_config_file(
132132
@pytest.mark.usefixtures("tmp_commitizen_project")
133133
@pytest.mark.parametrize(
134134
"commit_msg",
135-
(
135+
[
136136
"feat: new user interface\n\nBREAKING CHANGE: age is no longer supported",
137137
"feat!: new user interface\n\nBREAKING CHANGE: age is no longer supported",
138138
"feat!: new user interface",
@@ -141,7 +141,7 @@ def test_bump_minor_increment_signed_config_file(
141141
"feat(user)!: new user interface",
142142
"BREAKING CHANGE: age is no longer supported",
143143
"BREAKING-CHANGE: age is no longer supported",
144-
),
144+
],
145145
)
146146
def test_bump_major_increment(commit_msg: str, util: UtilFixture):
147147
util.create_file_and_commit(commit_msg)
@@ -152,7 +152,7 @@ def test_bump_major_increment(commit_msg: str, util: UtilFixture):
152152
@pytest.mark.usefixtures("tmp_commitizen_project")
153153
@pytest.mark.parametrize(
154154
"commit_msg",
155-
(
155+
[
156156
"feat: new user interface\n\nBREAKING CHANGE: age is no longer supported",
157157
"feat!: new user interface\n\nBREAKING CHANGE: age is no longer supported",
158158
"feat!: new user interface",
@@ -161,7 +161,7 @@ def test_bump_major_increment(commit_msg: str, util: UtilFixture):
161161
"feat(user)!: new user interface",
162162
"BREAKING CHANGE: age is no longer supported",
163163
"BREAKING-CHANGE: age is no longer supported",
164-
),
164+
],
165165
)
166166
def test_bump_major_increment_major_version_zero(commit_msg: str, util: UtilFixture):
167167
util.create_file_and_commit(commit_msg)
@@ -171,7 +171,7 @@ def test_bump_major_increment_major_version_zero(commit_msg: str, util: UtilFixt
171171

172172
@pytest.mark.usefixtures("tmp_commitizen_project")
173173
@pytest.mark.parametrize(
174-
"commit_msg,increment,expected_tag",
174+
("commit_msg", "increment", "expected_tag"),
175175
[
176176
("feat: new file", "PATCH", "0.1.1"),
177177
("fix: username exception", "major", "1.0.0"),
@@ -607,7 +607,7 @@ def test_bump_with_git_to_stdout_arg(util: UtilFixture, capsys: pytest.CaptureFi
607607

608608

609609
@pytest.mark.parametrize(
610-
"version_filepath, version_regex, version_file_content",
610+
("version_filepath", "version_regex", "version_file_content"),
611611
[
612612
pytest.param(
613613
"pyproject.toml",
@@ -779,7 +779,7 @@ def test_bump_manual_version_disallows_major_version_zero(util: UtilFixture):
779779

780780

781781
@pytest.mark.parametrize(
782-
"initial_version, expected_version_after_bump",
782+
("initial_version", "expected_version_after_bump"),
783783
[
784784
("1", "1.1.0"),
785785
("1.2", "1.3.0"),
@@ -804,7 +804,7 @@ def test_bump_version_with_less_components_in_config(
804804
assert expected_version_after_bump in f.read()
805805

806806

807-
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
807+
@pytest.mark.parametrize("commit_msg", ["feat: new file", "feat(user): new file"])
808808
def test_bump_with_pre_bump_hooks(
809809
commit_msg, mocker: MockFixture, tmp_commitizen_project, util: UtilFixture
810810
):
@@ -992,7 +992,7 @@ def test_bump_command_prerelease_scheme_check_old_tags(
992992
@pytest.mark.usefixtures("tmp_commitizen_project")
993993
@pytest.mark.usefixtures("use_cz_semver")
994994
@pytest.mark.parametrize(
995-
"message, expected_tag",
995+
("message", "expected_tag"),
996996
[
997997
("minor: add users", "0.2.0"),
998998
("patch: bug affecting users", "0.1.1"),
@@ -1008,7 +1008,7 @@ def test_bump_with_plugin(util: UtilFixture, message: str, expected_tag: str):
10081008
@pytest.mark.usefixtures("tmp_commitizen_project")
10091009
@pytest.mark.usefixtures("use_cz_semver")
10101010
@pytest.mark.parametrize(
1011-
"message, expected_tag",
1011+
("message", "expected_tag"),
10121012
[
10131013
("minor: add users", "0.2.0"),
10141014
("patch: bug affecting users", "0.1.1"),
@@ -1060,14 +1060,14 @@ def test_bump_command_version_scheme_priority_over_version_type(util: UtilFixtur
10601060

10611061

10621062
@pytest.mark.parametrize(
1063-
"arg, cfg, expected",
1064-
(
1063+
("arg", "cfg", "expected"),
1064+
[
10651065
pytest.param("", "", "default", id="default"),
10661066
pytest.param("", "changelog.cfg", "from config", id="from-config"),
10671067
pytest.param(
10681068
"--template=changelog.cmd", "changelog.cfg", "from cmd", id="from-command"
10691069
),
1070-
),
1070+
],
10711071
)
10721072
def test_bump_template_option_precedence(
10731073
tmp_commitizen_project: Path,

tests/commands/test_changelog_command.py

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def test_changelog_incremental_with_release_candidate_version(
692692

693693

694694
@pytest.mark.parametrize(
695-
"from_pre,to_pre", itertools.product(["alpha", "beta", "rc"], repeat=2)
695+
("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
696696
)
697697
@pytest.mark.usefixtures("tmp_commitizen_project")
698698
@pytest.mark.freeze_time("2021-06-11")
@@ -856,13 +856,13 @@ def test_changelog_from_rev_latest_version_from_arg(
856856

857857
@pytest.mark.usefixtures("tmp_commitizen_project")
858858
@pytest.mark.parametrize(
859-
"rev_range,tag",
860-
(
859+
("rev_range", "tag"),
860+
[
861861
pytest.param("0.8.0", "0.2.0", id="single-not-found"),
862862
pytest.param("0.1.0..0.3.0", "0.3.0", id="lower-bound-not-found"),
863863
pytest.param("0.1.0..0.3.0", "0.1.0", id="upper-bound-not-found"),
864864
pytest.param("0.3.0..0.4.0", "0.2.0", id="none-found"),
865-
),
865+
],
866866
)
867867
def test_changelog_from_rev_range_not_found(
868868
config_path: Path, rev_range: str, tag: str, util: UtilFixture
@@ -1270,14 +1270,14 @@ def test_changelog_from_current_version_tag_with_nonversion_tag(
12701270

12711271

12721272
@pytest.mark.parametrize(
1273-
"arg,cfg,expected",
1274-
(
1273+
("arg", "cfg", "expected"),
1274+
[
12751275
pytest.param("", "", "default", id="default"),
12761276
pytest.param("", "changelog.cfg", "from config", id="from-config"),
12771277
pytest.param(
12781278
"--template=changelog.cmd", "changelog.cfg", "from cmd", id="from-command"
12791279
),
1280-
),
1280+
],
12811281
)
12821282
def test_changelog_template_option_precedence(
12831283
tmp_commitizen_project: Path,
@@ -1588,12 +1588,12 @@ def test_changelog_template_extra_quotes(
15881588

15891589

15901590
@pytest.mark.parametrize(
1591-
"extra, expected",
1592-
(
1591+
("extra", "expected"),
1592+
[
15931593
pytest.param("key=value=", "value=", id="2-equals"),
15941594
pytest.param("key==value", "=value", id="2-consecutive-equals"),
15951595
pytest.param("key==value==", "=value==", id="multiple-equals"),
1596-
),
1596+
],
15971597
)
15981598
def test_changelog_template_extra_weird_but_valid(
15991599
changelog_tpl: Path,
@@ -1609,7 +1609,7 @@ def test_changelog_template_extra_weird_but_valid(
16091609
assert changelog_file.read_text() == expected
16101610

16111611

1612-
@pytest.mark.parametrize("extra", ("no-equal", "", "=no-key"))
1612+
@pytest.mark.parametrize("extra", ["no-equal", "", "=no-key"])
16131613
def test_changelog_template_extra_bad_format(
16141614
changelog_tpl: Path,
16151615
extra: str,
@@ -1672,3 +1672,57 @@ class FakeTemplate:
16721672

16731673
assert not changelog_jinja_file.exists()
16741674
assert "Template filename is not set" in str(exc_info.value)
1675+
1676+
1677+
def test_changelog_template_incremental_variable(
1678+
tmp_commitizen_project: Path,
1679+
any_changelog_format: ChangelogFormat,
1680+
util: UtilFixture,
1681+
file_regression: FileRegressionFixture,
1682+
):
1683+
"""
1684+
Test that the changelog template is not rendered when the incremental flag is not set.
1685+
Reference: https://github.com/commitizen-tools/commitizen/discussions/1620
1686+
"""
1687+
project_root = Path(tmp_commitizen_project)
1688+
changelog_tpl = project_root / any_changelog_format.template
1689+
changelog_tpl.write_text(
1690+
dedent("""
1691+
{% if not incremental %}
1692+
# CHANGELOG
1693+
{% endif %}
1694+
1695+
{% for entry in tree %}
1696+
1697+
## {{ entry.version }}{% if entry.date %} ({{ entry.date }}){% endif %}
1698+
1699+
{% for change_key, changes in entry.changes.items() %}
1700+
1701+
{% if change_key %}
1702+
### {{ change_key }}
1703+
{% endif %}
1704+
1705+
{% for change in changes %}
1706+
{% if change.scope %}
1707+
- **{{ change.scope }}**: {{ change.message }}
1708+
{% elif change.message %}
1709+
- {{ change.message }}
1710+
{% endif %}
1711+
{% endfor %}
1712+
{% endfor %}
1713+
{% endfor %}
1714+
""")
1715+
)
1716+
target = "CHANGELOG.md"
1717+
1718+
util.create_file_and_commit("feat(foo): new file")
1719+
util.run_cli("changelog", "--file-name", target)
1720+
with open(target, encoding="utf-8") as f:
1721+
out = f.read()
1722+
file_regression.check(out, extension=".md")
1723+
1724+
util.create_file_and_commit("refactor(bar): another new file")
1725+
util.run_cli("changelog", "--file-name", target, "--incremental")
1726+
with open(target, encoding="utf-8") as f:
1727+
out = f.read()
1728+
file_regression.check(out, extension=".incremental.md")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# CHANGELOG
2+
3+
4+
## Unreleased
5+
6+
### Feat
7+
8+
- **foo**: new file
9+
10+
### Refactor
11+
12+
- **bar**: another new file
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CHANGELOG
2+
3+
4+
## Unreleased
5+
6+
### Feat
7+
8+
- **foo**: new file

0 commit comments

Comments
 (0)