Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(commands/bump): prevent using incremental changelog when it is set to false in config #996

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ def __call__(self) -> None: # noqa: C901
"unreleased_version": new_tag_version,
"template": self.template,
"extras": self.extras,
"incremental": True,
"incremental": self.config.mutated_settings.get(
"changelog_incremental", True
),
"dry_run": True,
},
)
Expand All @@ -305,7 +307,9 @@ def __call__(self) -> None: # noqa: C901
self.config,
{
"unreleased_version": new_tag_version,
"incremental": True,
"incremental": self.config.mutated_settings.get(
"changelog_incremental", True
),
"dry_run": dry_run,
"template": self.template,
"extras": self.extras,
Expand Down
10 changes: 10 additions & 0 deletions commitizen/config/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ def __init__(self):
self._settings: Settings = DEFAULT_SETTINGS.copy()
self.encoding = self.settings["encoding"]
self._path: Path | None = None
self._settings_from_configs: Settings = {}

@property
def settings(self) -> Settings:
return self._settings

@property
def mutated_settings(self) -> Settings:
"""It is used to record the changes from the config file defined by users,
which helps distinguish the ambiguous default behavior of
`changelog_incremental`.
Please refer to https://github.com/commitizen-tools/commitizen/pull/996
"""
return self._settings_from_configs

@property
def path(self) -> Path | None:
return self._path
Expand Down
1 change: 1 addition & 0 deletions commitizen/config/json_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ def _parse_setting(self, data: bytes | str) -> None:

try:
self.settings.update(doc["commitizen"])
self.mutated_settings.update(doc["commitizen"])
except KeyError:
self.is_empty_config = True
1 change: 1 addition & 0 deletions commitizen/config/toml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ def _parse_setting(self, data: bytes | str) -> None:

try:
self.settings.update(doc["tool"]["commitizen"]) # type: ignore
self.mutated_settings.update(doc["tool"]["commitizen"]) # type: ignore
except exceptions.NonExistentKey:
self.is_empty_config = True
1 change: 1 addition & 0 deletions commitizen/config/yaml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def _parse_setting(self, data: bytes | str) -> None:

try:
self.settings.update(doc["commitizen"])
self.mutated_settings.update(doc["commitizen"])
except (KeyError, TypeError):
self.is_empty_config = True

Expand Down