Skip to content
Merged
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
4 changes: 2 additions & 2 deletions commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __call__(self):
current_tag_version: str = bump.create_tag(
current_version, tag_format=tag_format
)
files: list = self.parameters["files"]
version_files: list = self.parameters["version_files"]
dry_run: bool = self.parameters["dry_run"]

is_yes: bool = self.arguments["yes"]
Expand Down Expand Up @@ -124,7 +124,7 @@ def __call__(self):
if dry_run:
raise SystemExit()

bump.update_version_in_files(current_version, new_version.public, files)
bump.update_version_in_files(current_version, new_version.public, version_files)
if is_files_only:
raise SystemExit()

Expand Down
14 changes: 14 additions & 0 deletions commitizen/config/base_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from typing import Optional

from commitizen.defaults import DEFAULT_SETTINGS
Expand Down Expand Up @@ -32,3 +33,16 @@ def add_path(self, path: str):

def _parse_setting(self, data: str) -> dict:
raise NotImplementedError()

# TODO: remove "files" supported in 2.0
@classmethod
def _show_files_column_deprecated_warning(cls):
warnings.simplefilter("always", DeprecationWarning)
warnings.warn(
(
'"files" is renamed as "version_files" '
"and will be deprecated in next major version\n"
'Please repalce "files" with "version_files"'
),
category=DeprecationWarning,
)
13 changes: 7 additions & 6 deletions commitizen/config/ini_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ def _parse_setting(self, data: str):
try:
_data: dict = dict(config["commitizen"])
if "files" in _data:
files = _data["files"]
_f = json.loads(files)
_data.update({"files": _f})
IniConfig._show_files_column_deprecated_warning()
_data.update({"version_files": json.loads(_data["files"])})

if "version_files" in _data:
_data.update({"version_files": json.loads(_data["version_files"])})

if "style" in _data:
style = _data["style"]
_s = json.loads(style)
_data.update({"style": _s})
_data.update({"style": json.loads(_data["style"])})

self._settings.update(_data)
except KeyError:
Expand Down
4 changes: 4 additions & 0 deletions commitizen/config/toml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ def _parse_setting(self, data: str):
self.settings.update(doc["tool"]["commitizen"])
except exceptions.NonExistentKey:
self.is_empty_config = True

if "files" in self.settings:
self.settings["version_files"] = self.settings["files"]
TomlConfig._show_files_column_deprecated_warning
3 changes: 1 addition & 2 deletions commitizen/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
# TODO: .cz, setup.cfg, .cz.cfg should be removed in 2.0
config_files: list = ["pyproject.toml", ".cz.toml", ".cz", "setup.cfg", ".cz.cfg"]


DEFAULT_SETTINGS = {
"name": "cz_conventional_commits",
"version": None,
"files": [],
"version_files": [],
"tag_format": None, # example v$version
"bump_message": None, # bumped v$current_version to $new_version
}
Expand Down
10 changes: 5 additions & 5 deletions tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[tool.commitizen]
name = "cz_jira"
version = "1.0.0"
files = [
version_files = [
"commitizen/__version__.py",
"pyproject.toml"
]
Expand All @@ -26,7 +26,7 @@
[commitizen]
name = cz_jira
version = 1.0.0
files = [
version_files = [
"commitizen/__version__.py",
"pyproject.toml"
]
Expand All @@ -41,7 +41,7 @@
"version": "1.0.0",
"tag_format": None,
"bump_message": None,
"files": ["commitizen/__version__.py", "pyproject.toml"],
"version_files": ["commitizen/__version__.py", "pyproject.toml"],
"style": [["pointer", "reverse"], ["question", "underline"]],
}

Expand All @@ -50,14 +50,14 @@
"version": "2.0.0",
"tag_format": None,
"bump_message": None,
"files": ["commitizen/__version__.py", "pyproject.toml"],
"version_files": ["commitizen/__version__.py", "pyproject.toml"],
"style": [["pointer", "reverse"], ["question", "underline"]],
}

_read_settings = {
"name": "cz_jira",
"version": "1.0.0",
"files": ["commitizen/__version__.py", "pyproject.toml"],
"version_files": ["commitizen/__version__.py", "pyproject.toml"],
"style": [["pointer", "reverse"], ["question", "underline"]],
}

Expand Down