Skip to content

Commit 5e612bf

Browse files
committed
Merge branch 'master' into bump-rule-interface
2 parents 537904e + 8d57306 commit 5e612bf

File tree

11 files changed

+29
-24
lines changed

11 files changed

+29
-24
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ repos:
4848
- tomli
4949

5050
- repo: https://github.com/commitizen-tools/commitizen
51-
rev: v4.7.1 # automatically updated by Commitizen
51+
rev: v4.7.2 # automatically updated by Commitizen
5252
hooks:
5353
- id: commitizen
5454
- id: commitizen-branch

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v4.7.2 (2025-05-18)
2+
3+
### Refactor
4+
5+
- **default**: capitalize all constants and remove unnecessary variable
6+
17
## v4.7.1 (2025-05-16)
28

39
### Fix

commitizen/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.7.1"
1+
__version__ = "4.7.2"

commitizen/bump.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from glob import iglob
66
from string import Template
77

8-
from commitizen.defaults import bump_message, encoding
8+
from commitizen.defaults import BUMP_MESSAGE, ENCODING
99
from commitizen.exceptions import CurrentVersionNotFoundError
1010
from commitizen.git import smart_open
1111
from commitizen.version_schemes import Version
@@ -17,7 +17,7 @@ def update_version_in_files(
1717
files: list[str],
1818
*,
1919
check_consistency: bool = False,
20-
encoding: str = encoding,
20+
encoding: str = ENCODING,
2121
) -> list[str]:
2222
"""Change old version to the new one in every file given.
2323
@@ -74,7 +74,7 @@ def _bump_with_regex(
7474
current_version: str,
7575
new_version: str,
7676
regex: str,
77-
encoding: str = encoding,
77+
encoding: str = ENCODING,
7878
) -> tuple[bool, str]:
7979
current_version_found = False
8080
lines = []
@@ -101,6 +101,6 @@ def create_commit_message(
101101
message_template: str | None = None,
102102
) -> str:
103103
if message_template is None:
104-
message_template = bump_message
104+
message_template = BUMP_MESSAGE
105105
t = Template(message_template)
106106
return t.safe_substitute(current_version=current_version, new_version=new_version)

commitizen/commands/changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, config: BaseConfig, args):
7878
self.change_type_order = (
7979
self.config.settings.get("change_type_order")
8080
or self.cz.change_type_order
81-
or defaults.change_type_order
81+
or defaults.CHANGE_TYPE_ORDER
8282
)
8383
self.rev_range = args.get("rev_range")
8484
self.tag_format: str = (

commitizen/commands/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from commitizen.__version__ import __version__
1212
from commitizen.config import BaseConfig, JsonConfig, TomlConfig, YAMLConfig
1313
from commitizen.cz import registry
14-
from commitizen.defaults import DEFAULT_SETTINGS, config_files
14+
from commitizen.defaults import CONFIG_FILES, DEFAULT_SETTINGS
1515
from commitizen.exceptions import InitFailedError, NoAnswersError
1616
from commitizen.git import get_latest_tag_name, get_tag_names, smart_open
1717
from commitizen.version_schemes import KNOWN_SCHEMES, Version, get_version_scheme
@@ -165,7 +165,7 @@ def _ask_config_path(self) -> str:
165165

166166
name: str = questionary.select(
167167
"Please choose a supported config file: ",
168-
choices=config_files,
168+
choices=CONFIG_FILES,
169169
default=default_path,
170170
style=self.cz.style,
171171
).unsafe_ask()

commitizen/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def read_cfg(filepath: str | None = None) -> BaseConfig:
2828
cfg_paths = (
2929
path / Path(filename)
3030
for path in cfg_search_paths
31-
for filename in defaults.config_files
31+
for filename in defaults.CONFIG_FILES
3232
)
3333

3434
for filename in cfg_paths:

commitizen/cz/customize/customize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CustomizeCommitsCz(BaseCommitizen):
2424
bump_pattern = defaults.BUMP_PATTERN
2525
bump_map = defaults.BUMP_MAP
2626
bump_map_major_version_zero = defaults.BUMP_MAP_MAJOR_VERSION_ZERO
27-
change_type_order = defaults.change_type_order
27+
change_type_order = defaults.CHANGE_TYPE_ORDER
2828

2929
def __init__(self, config: BaseConfig):
3030
super().__init__(config)

commitizen/defaults.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class Settings(TypedDict, total=False):
6262
extras: dict[str, Any]
6363

6464

65-
name: str = "cz_conventional_commits"
66-
config_files: list[str] = [
65+
CONFIG_FILES: list[str] = [
6766
"pyproject.toml",
6867
".cz.toml",
6968
".cz.json",
@@ -72,10 +71,10 @@ class Settings(TypedDict, total=False):
7271
"cz.yaml",
7372
"cz.toml",
7473
]
75-
encoding: str = "utf-8"
74+
ENCODING = "utf-8"
7675

7776
DEFAULT_SETTINGS: Settings = {
78-
"name": name,
77+
"name": "cz_conventional_commits",
7978
"version": None,
8079
"version_files": [],
8180
"version_provider": "commitizen",
@@ -104,7 +103,7 @@ class Settings(TypedDict, total=False):
104103
"pre_bump_hooks": [],
105104
"post_bump_hooks": [],
106105
"prerelease_offset": 0,
107-
"encoding": encoding,
106+
"encoding": ENCODING,
108107
"always_signoff": False,
109108
"template": None, # default provided by plugin
110109
"extras": {},
@@ -113,7 +112,7 @@ class Settings(TypedDict, total=False):
113112
CHANGELOG_FORMAT = "markdown"
114113

115114
BUMP_PATTERN = r"^((BREAKING[\-\ ]CHANGE|\w+)(\(.+\))?!?):"
116-
BUMP_MAP = dict(
115+
BUMP_MAP = OrderedDict(
117116
(
118117
(r"^.+!$", str(SemVerIncrement.MAJOR)),
119118
(r"^BREAKING[\-\ ]CHANGE", str(SemVerIncrement.MAJOR)),
@@ -123,7 +122,7 @@ class Settings(TypedDict, total=False):
123122
(r"^perf", str(SemVerIncrement.PATCH)),
124123
)
125124
)
126-
BUMP_MAP_MAJOR_VERSION_ZERO = dict(
125+
BUMP_MAP_MAJOR_VERSION_ZERO = OrderedDict(
127126
(
128127
(r"^.+!$", str(SemVerIncrement.MINOR)),
129128
(r"^BREAKING[\-\ ]CHANGE", str(SemVerIncrement.MINOR)),
@@ -133,8 +132,8 @@ class Settings(TypedDict, total=False):
133132
(r"^perf", str(SemVerIncrement.PATCH)),
134133
)
135134
)
136-
change_type_order = ["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"]
137-
bump_message = "bump: version $current_version → $new_version"
135+
CHANGE_TYPE_ORDER = ["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"]
136+
BUMP_MESSAGE = "bump: version $current_version → $new_version"
138137

139138

140139
def get_tag_regexes(

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "commitizen"
3-
version = "4.7.1"
3+
version = "4.7.2"
44
description = "Python commitizen client tool"
55
authors = [{ name = "Santiago Fraire", email = "[email protected]" }]
66
maintainers = [
@@ -88,7 +88,7 @@ build-backend = "poetry.core.masonry.api"
8888

8989

9090
[tool.commitizen]
91-
version = "4.7.1"
91+
version = "4.7.2"
9292
tag_format = "v$version"
9393
version_files = [
9494
"pyproject.toml:version",

tests/test_conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_find_git_project_root(tmpdir):
151151

152152

153153
@pytest.mark.parametrize(
154-
"config_files_manager", defaults.config_files.copy(), indirect=True
154+
"config_files_manager", defaults.CONFIG_FILES.copy(), indirect=True
155155
)
156156
def test_set_key(config_files_manager):
157157
_conf = config.read_cfg()
@@ -162,7 +162,7 @@ def test_set_key(config_files_manager):
162162

163163
class TestReadCfg:
164164
@pytest.mark.parametrize(
165-
"config_files_manager", defaults.config_files.copy(), indirect=True
165+
"config_files_manager", defaults.CONFIG_FILES.copy(), indirect=True
166166
)
167167
def test_load_conf(_, config_files_manager):
168168
cfg = config.read_cfg()

0 commit comments

Comments
 (0)