Skip to content

Commit

Permalink
fix(commands/bump): prevent using incremental changelog when it is se…
Browse files Browse the repository at this point in the history
…t to false in config
  • Loading branch information
josix committed Feb 29, 2024
1 parent fc54b51 commit 45b9352
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
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
5 changes: 5 additions & 0 deletions commitizen/config/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ 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:
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

0 comments on commit 45b9352

Please sign in to comment.