Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c001f3d

Browse files
committed
refactor(config): remove ini configuration support
BREAKING CHANGE: setup.cfg, .cz and .cz.cfg are no longer supported
1 parent 99dfb5a commit c001f3d

File tree

8 files changed

+7
-223
lines changed

8 files changed

+7
-223
lines changed

‎commitizen/commands/init.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from packaging.version import Version
33

44
from commitizen import factory, out
5-
from commitizen.config import BaseConfig, IniConfig, TomlConfig
5+
from commitizen.config import BaseConfig, TomlConfig
66
from commitizen.cz import registry
7-
from commitizen.defaults import long_term_support_config_files
7+
from commitizen.defaults import config_files
88
from commitizen.exceptions import NoAnswersError
99
from commitizen.git import get_latest_tag_name, get_tag_names
1010

@@ -23,8 +23,6 @@ def __call__(self):
2323

2424
if "toml" in config_path:
2525
self.config = TomlConfig(data="", path=config_path)
26-
else:
27-
self.config = IniConfig(data="", path=config_path)
2826

2927
self.config.init_empty_config_content()
3028

@@ -43,7 +41,7 @@ def __call__(self):
4341
def _ask_config_path(self) -> str:
4442
name = questionary.select(
4543
"Please choose a supported config file: (default: pyproject.toml)",
46-
choices=long_term_support_config_files,
44+
choices=config_files,
4745
default="pyproject.toml",
4846
style=self.cz.style,
4947
).ask()

‎commitizen/config/__init__.py‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
1-
import warnings
21
from pathlib import Path
3-
from typing import Optional, Union
42

53
from commitizen import defaults, git
64

75
from .base_config import BaseConfig
8-
from .ini_config import IniConfig
96
from .toml_config import TomlConfig
107

118

12-
def load_global_conf() -> Optional[IniConfig]:
13-
home = Path.home()
14-
global_cfg = home / Path(".cz")
15-
if not global_cfg.exists():
16-
return None
17-
18-
# global conf doesn't make sense with commitizen bump
19-
# so I'm deprecating it and won't test it
20-
message = (
21-
"Global conf will be deprecated in next major version. "
22-
"Use per project configuration. "
23-
"Remove '~/.cz' file from your conf folder."
24-
)
25-
warnings.simplefilter("always", DeprecationWarning)
26-
warnings.warn(message, category=DeprecationWarning)
27-
28-
with open(global_cfg, "r") as f:
29-
data = f.read()
30-
31-
conf = IniConfig(data=data, path=global_cfg)
32-
return conf
33-
34-
359
def read_cfg() -> BaseConfig:
3610
conf = BaseConfig()
3711

@@ -52,21 +26,14 @@ def read_cfg() -> BaseConfig:
5226
with open(filename, "r") as f:
5327
data: str = f.read()
5428

55-
_conf: Union[TomlConfig, IniConfig]
29+
_conf: TomlConfig
5630
if "toml" in filename.suffix:
5731
_conf = TomlConfig(data=data, path=filename)
58-
else:
59-
_conf = IniConfig(data=data, path=filename)
6032

6133
if _conf.is_empty_config:
6234
continue
6335
else:
6436
conf = _conf
6537
break
6638

67-
if not conf.path:
68-
global_conf = load_global_conf()
69-
if global_conf:
70-
conf = global_conf
71-
7239
return conf

‎commitizen/config/ini_config.py‎

Lines changed: 0 additions & 76 deletions
This file was deleted.

‎commitizen/defaults.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
from collections import OrderedDict
2-
from typing import Any, Dict
2+
from typing import Any, Dict, List
33

44
name: str = "cz_conventional_commits"
5-
# TODO: .cz, setup.cfg, .cz.cfg should be removed in 2.0
6-
long_term_support_config_files: list = ["pyproject.toml", ".cz.toml"]
7-
deprcated_config_files: list = [".cz", "setup.cfg", ".cz.cfg"]
8-
config_files: list = long_term_support_config_files + deprcated_config_files
5+
config_files: List[str] = ["pyproject.toml", ".cz.toml"]
96

107
DEFAULT_SETTINGS: Dict[str, Any] = {
118
"name": "cz_conventional_commits",

‎docs/bump.md‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ However, it will still update `pyproject.toml` and `src/__version__.py`.
131131
To fix it, you'll first `git checkout .` to reset to the status before trying to bump and update
132132
the version in `setup.py` to `1.21.0`
133133

134-
135134
## Configuration
136135

137136
### `tag_format`
@@ -155,13 +154,6 @@ In your `pyproject.toml` or `.cz.toml`
155154
tag_format = "v$minor.$major.$patch$prerelease"
156155
```
157156

158-
Or in your `.cz` (TO BE DEPRECATED)
159-
160-
```ini
161-
[commitizen]
162-
tag_format = v$minor.$major.$patch$prerelease
163-
```
164-
165157
The variables must be preceded by a `$` sign.
166158

167159
Supported variables:
@@ -198,16 +190,6 @@ version_files = [
198190
]
199191
```
200192

201-
`.cz` (TO BE DEPRECATED)
202-
203-
```ini
204-
[commitizen]
205-
version_files = [
206-
"src/__version__.py",
207-
"setup.py:version"
208-
]
209-
```
210-
211193
In the example above, we can see the reference `"setup.py:version"`.
212194
This means that it will find a file `setup.py` and will only make a change
213195
in a line containing the `version` substring.
@@ -234,13 +216,6 @@ Some examples
234216
bump_message = "release $current_version → $new_version [skip-ci]"
235217
```
236218

237-
`.cz` (TO BE DEPRECATED)
238-
239-
```ini
240-
[commitizen]
241-
bump_message = release $current_version → $new_version [skip-ci]
242-
```
243-
244219
## Custom bump
245220

246221
Read the [customizing section](./customization.md).

‎docs/config.md‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Configuration
22

3-
Commitizen has support for `toml` and `ini` files. It first looks up the configuration file in the current working directory and then the root directory of the git project.
4-
53
## pyproject.toml or .cz.toml
64

75
Add an entry to `pyproject.toml` or `.cz.toml`. Recommended for **python** projects.
@@ -28,38 +26,7 @@ style = [
2826
]
2927
```
3028

31-
## INI files
32-
33-
**INI files will not be supported in the next major version. Please use toml instead**
34-
35-
Supported files: `.cz`, `.cz.cfg`, `setup.cfg`, and `$HOME/.cz`
36-
37-
The format is slightly different to the `toml`, so pay attention.
38-
Recommended for **other languages** projects (js, go, etc).
39-
40-
```ini
41-
[commitizen]
42-
name = cz_conventional_commits
43-
version = 0.1.0
44-
version_files = [
45-
"src/__version__.py",
46-
"pyproject.toml:version"
47-
]
48-
style = [
49-
["qmark", "fg:#ff9d00 bold"],
50-
["question", "bold"],
51-
["answer", "fg:#ff9d00 bold"],
52-
["pointer", "fg:#ff9d00 bold"],
53-
["highlighted", "fg:#ff9d00 bold"],
54-
["selected", "fg:#cc5454"],
55-
["separator", "fg:#cc5454"],
56-
["instruction", ""],
57-
["text", ""],
58-
["disabled", "fg:#858585 italic"]
59-
]
60-
```
61-
62-
The extra tab before the square brackets (`]`) at the end is required.
29+
`.cz.toml` is recommended for **other languages** projects (js, go, etc).
6330

6431
## Settings
6532

‎tests/test_cli.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44

55
from commitizen import cli
6-
from commitizen.__version__ import __version__
76
from commitizen.exceptions import ExpectedExit, NoCommandFoundError, NotAGitProjectError
87

98

‎tests/test_conf.py‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@
2323
target-version = ['py36', 'py37', 'py38']
2424
"""
2525

26-
RAW_CONFIG = """
27-
[commitizen]
28-
name = cz_jira
29-
version = 1.0.0
30-
version_files = [
31-
"commitizen/__version__.py",
32-
"pyproject.toml"
33-
]
34-
style = [
35-
["pointer", "reverse"],
36-
["question", "underline"]
37-
]
38-
"""
3926

4027
_settings = {
4128
"name": "cz_jira",
@@ -83,33 +70,17 @@ def config_files_manager(request):
8370
with open(filepath, "w") as f:
8471
if "toml" in filename:
8572
f.write(PYPROJECT)
86-
else:
87-
f.write(RAW_CONFIG)
8873
yield
8974
os.remove(filepath)
9075

9176

9277
@pytest.fixture
9378
def empty_pyproject_ok_cz():
9479
pyproject = "tests/pyproject.toml"
95-
cz = "tests/.cz"
9680
with open(pyproject, "w") as f:
9781
f.write("")
98-
with open(cz, "w") as f:
99-
f.write(RAW_CONFIG)
10082
yield
10183
os.remove(pyproject)
102-
os.remove(cz)
103-
104-
105-
def test_load_global_conf(mocker, tmpdir):
106-
with tmpdir.as_cwd():
107-
config_file = tmpdir.join(".cz")
108-
config_file.write(RAW_CONFIG)
109-
110-
mocked_path = mocker.patch("commitizen.config.Path", return_value=Path(".cz"))
111-
mocked_path.home.return_value = Path(tmpdir)
112-
print(config.load_global_conf())
11384

11485

11586
@pytest.mark.parametrize(
@@ -120,13 +91,6 @@ def test_load_conf(config_files_manager, configure_supported_files):
12091
assert cfg.settings == _settings
12192

12293

123-
def test_conf_is_loaded_with_empty_pyproject_but_ok_cz(
124-
empty_pyproject_ok_cz, configure_supported_files
125-
):
126-
cfg = config.read_cfg()
127-
assert cfg.settings == _settings
128-
129-
13094
def test_conf_returns_default_when_no_files(configure_supported_files):
13195
cfg = config.read_cfg()
13296
assert cfg.settings == defaults.DEFAULT_SETTINGS
@@ -149,13 +113,6 @@ def test_find_git_project_root(tmpdir):
149113
assert git.find_git_project_root() is None
150114

151115

152-
class TestInilConfig:
153-
def test_read_setup_cfg_without_commitizen_config(self, tmpdir):
154-
path = tmpdir.mkdir("commitizen").join("setup.cfg")
155-
ini_config = config.IniConfig(data="", path=path)
156-
assert ini_config.is_empty_config
157-
158-
159116
class TestTomlConfig:
160117
def test_init_empty_config_content(self, tmpdir):
161118
path = tmpdir.mkdir("commitizen").join(".cz.toml")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /