Skip to content

Commit b787be6

Browse files
committed
refactor(bump_rule): rename function
1 parent 33f8d59 commit b787be6

File tree

3 files changed

+131
-114
lines changed

3 files changed

+131
-114
lines changed

commitizen/bump_rule.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ def safe_cast_dict(cls, d: Mapping[str, object]) -> dict[str, VersionIncrement]:
4545
@staticmethod
4646
def get_highest_by_messages(
4747
commit_messages: Iterable[str],
48-
get_increment: Callable[[str], VersionIncrement | None],
48+
extract_increment: Callable[[str], VersionIncrement | None],
4949
) -> VersionIncrement | None:
5050
"""Find the highest version increment from a list of messages.
5151
5252
This function processes a list of messages and determines the highest version
5353
increment needed based on the commit messages. It splits multi-line commit messages
54-
and evaluates each line using the provided get_increment callable.
54+
and evaluates each line using the provided extract_increment callable.
5555
5656
Args:
5757
commit_messages: A list of messages to analyze.
58-
get_increment: A callable that takes a commit message string and returns an
58+
extract_increment: A callable that takes a commit message string and returns an
5959
VersionIncrement value (MAJOR, MINOR, PATCH) or None if no increment is needed.
6060
6161
Returns:
@@ -65,11 +65,11 @@ def get_highest_by_messages(
6565
Example:
6666
>>> commit_messages = ["feat: new feature", "fix: bug fix"]
6767
>>> rule = ConventionalCommitBumpRule()
68-
>>> VersionIncrement.get_highest_by_messages(commit_messages, lambda x: rule.get_increment(x, False))
68+
>>> VersionIncrement.get_highest_by_messages(commit_messages, lambda x: rule.extract_increment(x, False))
6969
'MINOR'
7070
"""
7171
return VersionIncrement.get_highest(
72-
get_increment(line)
72+
extract_increment(line)
7373
for message in commit_messages
7474
for line in message.split("\n")
7575
)
@@ -92,7 +92,7 @@ class BumpRule(Protocol):
9292
such as conventional commits or custom rules.
9393
"""
9494

95-
def get_increment(
95+
def extract_increment(
9696
self, commit_message: str, major_version_zero: bool
9797
) -> VersionIncrement | None:
9898
"""Determine the version increment based on a commit message.
@@ -120,7 +120,7 @@ class ConventionalCommitBumpRule(BumpRule):
120120
_MINOR_CHANGE_TYPES = set(["feat"])
121121
_PATCH_CHANGE_TYPES = set(["fix", "perf", "refactor"])
122122

123-
def get_increment(
123+
def extract_increment(
124124
self, commit_message: str, major_version_zero: bool
125125
) -> VersionIncrement | None:
126126
if not (m := self._head_pattern.match(commit_message)):
@@ -223,7 +223,7 @@ def __init__(
223223
self.bump_map = bump_map
224224
self.bump_map_major_version_zero = bump_map_major_version_zero
225225

226-
def get_increment(
226+
def extract_increment(
227227
self, commit_message: str, major_version_zero: bool
228228
) -> VersionIncrement | None:
229229
if not (m := self.bump_pattern.search(commit_message)):

commitizen/commands/bump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _find_increment(self, commits: list[git.GitCommit]) -> VersionIncrement | No
150150

151151
return VersionIncrement.get_highest_by_messages(
152152
(commit.message for commit in commits),
153-
lambda x: self.cz.bump_rule.get_increment(x, is_major_version_zero),
153+
lambda x: self.cz.bump_rule.extract_increment(x, is_major_version_zero),
154154
)
155155

156156
def __call__(self) -> None:

0 commit comments

Comments
 (0)