Skip to content

Commit d1d4415

Browse files
authored
Merge pull request #103 from Lee-W/rename-files-to-version_files
Rename files to version files
2 parents d9f675a + 797ed6d commit d1d4415

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

commitizen/commands/bump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __call__(self):
8181
current_tag_version: str = bump.create_tag(
8282
current_version, tag_format=tag_format
8383
)
84-
files: list = self.parameters["files"]
84+
version_files: list = self.parameters["version_files"]
8585
dry_run: bool = self.parameters["dry_run"]
8686

8787
is_yes: bool = self.arguments["yes"]
@@ -124,7 +124,7 @@ def __call__(self):
124124
if dry_run:
125125
raise SystemExit()
126126

127-
bump.update_version_in_files(current_version, new_version.public, files)
127+
bump.update_version_in_files(current_version, new_version.public, version_files)
128128
if is_files_only:
129129
raise SystemExit()
130130

commitizen/config/base_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from typing import Optional
23

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

3334
def _parse_setting(self, data: str) -> dict:
3435
raise NotImplementedError()
36+
37+
# TODO: remove "files" supported in 2.0
38+
@classmethod
39+
def _show_files_column_deprecated_warning(cls):
40+
warnings.simplefilter("always", DeprecationWarning)
41+
warnings.warn(
42+
(
43+
'"files" is renamed as "version_files" '
44+
"and will be deprecated in next major version\n"
45+
'Please repalce "files" with "version_files"'
46+
),
47+
category=DeprecationWarning,
48+
)

commitizen/config/ini_config.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ def _parse_setting(self, data: str):
5656
try:
5757
_data: dict = dict(config["commitizen"])
5858
if "files" in _data:
59-
files = _data["files"]
60-
_f = json.loads(files)
61-
_data.update({"files": _f})
59+
IniConfig._show_files_column_deprecated_warning()
60+
_data.update({"version_files": json.loads(_data["files"])})
61+
62+
if "version_files" in _data:
63+
_data.update({"version_files": json.loads(_data["version_files"])})
64+
6265
if "style" in _data:
63-
style = _data["style"]
64-
_s = json.loads(style)
65-
_data.update({"style": _s})
66+
_data.update({"style": json.loads(_data["style"])})
6667

6768
self._settings.update(_data)
6869
except KeyError:

commitizen/config/toml_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ def _parse_setting(self, data: str):
3737
self.settings.update(doc["tool"]["commitizen"])
3838
except exceptions.NonExistentKey:
3939
self.is_empty_config = True
40+
41+
if "files" in self.settings:
42+
self.settings["version_files"] = self.settings["files"]
43+
TomlConfig._show_files_column_deprecated_warning

commitizen/defaults.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
# TODO: .cz, setup.cfg, .cz.cfg should be removed in 2.0
33
config_files: list = ["pyproject.toml", ".cz.toml", ".cz", "setup.cfg", ".cz.cfg"]
44

5-
65
DEFAULT_SETTINGS = {
76
"name": "cz_conventional_commits",
87
"version": None,
9-
"files": [],
8+
"version_files": [],
109
"tag_format": None, # example v$version
1110
"bump_message": None, # bumped v$current_version to $new_version
1211
}

tests/test_conf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[tool.commitizen]
99
name = "cz_jira"
1010
version = "1.0.0"
11-
files = [
11+
version_files = [
1212
"commitizen/__version__.py",
1313
"pyproject.toml"
1414
]
@@ -26,7 +26,7 @@
2626
[commitizen]
2727
name = cz_jira
2828
version = 1.0.0
29-
files = [
29+
version_files = [
3030
"commitizen/__version__.py",
3131
"pyproject.toml"
3232
]
@@ -41,7 +41,7 @@
4141
"version": "1.0.0",
4242
"tag_format": None,
4343
"bump_message": None,
44-
"files": ["commitizen/__version__.py", "pyproject.toml"],
44+
"version_files": ["commitizen/__version__.py", "pyproject.toml"],
4545
"style": [["pointer", "reverse"], ["question", "underline"]],
4646
}
4747

@@ -50,14 +50,14 @@
5050
"version": "2.0.0",
5151
"tag_format": None,
5252
"bump_message": None,
53-
"files": ["commitizen/__version__.py", "pyproject.toml"],
53+
"version_files": ["commitizen/__version__.py", "pyproject.toml"],
5454
"style": [["pointer", "reverse"], ["question", "underline"]],
5555
}
5656

5757
_read_settings = {
5858
"name": "cz_jira",
5959
"version": "1.0.0",
60-
"files": ["commitizen/__version__.py", "pyproject.toml"],
60+
"version_files": ["commitizen/__version__.py", "pyproject.toml"],
6161
"style": [["pointer", "reverse"], ["question", "underline"]],
6262
}
6363

0 commit comments

Comments
 (0)