Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,16 @@ def __call__(self) -> None:
changelog_file_name = None
dry_run = self.arguments["dry_run"]
if self.changelog_flag:
# "changelog_incremental" defaults to None in settings, so we can't
# rely on .get(key, True); default to True for bump only when unset.
incremental_setting = self.config.settings.get("changelog_incremental")
changelog_args = {
"unreleased_version": new_tag_version,
"template": self.template,
"extras": self.extras,
"incremental": True,
"incremental": incremental_setting
if incremental_setting is not None
else True,
Comment on lines +321 to +323
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably also works and is less confusing

Suggested change
"incremental": incremental_setting
if incremental_setting is not None
else True,
"incremental": self.config.settings.get("changelog_incremental", True),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thanks for pointing it out.

Copy link
Contributor Author

@josix josix Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, seems that it will let tests fail, let me investigate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I found the root cause, dict.get only returns the fallback when the key is missing, so .get(..., True) would return None (not True). The explicit check is required to default to incremental changelog generation while still honoring an explicit False.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does remind me that Airflow has an ARG_NOT_SET thing. not sure whether we should have similiar mechanism

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll also need more context in this comment. same as the value in default.py. This is probably the best we can do for the time being, but worth thinking of a abetter solution in the following major versions. also would be great if we have a unit test to cover it

"dry_run": dry_run,
# governs logic for merge_prerelease
"during_version_bump": self.arguments["prerelease"] is None,
Expand Down
4 changes: 2 additions & 2 deletions commitizen/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Settings(TypedDict, total=False):
change_type_map: dict[str, str]
changelog_file: str
changelog_format: str | None
changelog_incremental: bool
changelog_incremental: bool | None
changelog_merge_prerelease: bool
changelog_start_rev: str | None
customize: CzSettings
Expand Down Expand Up @@ -100,7 +100,7 @@ class Settings(TypedDict, total=False):
],
"changelog_file": "CHANGELOG.md",
"changelog_format": None, # default guessed from changelog_file
"changelog_incremental": False,
"changelog_incremental": None,
"changelog_start_rev": None,
"changelog_merge_prerelease": False,
"update_changelog_on_bump": False,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"style": [["pointer", "reverse"], ["question", "underline"]],
"changelog_file": "CHANGELOG.md",
"changelog_format": None,
"changelog_incremental": False,
"changelog_incremental": None,
"changelog_start_rev": None,
"changelog_merge_prerelease": False,
"update_changelog_on_bump": False,
Expand Down Expand Up @@ -137,7 +137,7 @@
"style": [["pointer", "reverse"], ["question", "underline"]],
"changelog_file": "CHANGELOG.md",
"changelog_format": None,
"changelog_incremental": False,
"changelog_incremental": None,
"changelog_start_rev": None,
"changelog_merge_prerelease": False,
"update_changelog_on_bump": False,
Expand Down