Skip to content

Commit ac709ec

Browse files
committed
refactor(ConventionalCommitBumpRule): refactor
1 parent db8e93a commit ac709ec

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

commitizen/bump_rule.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def get_increment(
123123

124124

125125
class ConventionalCommitBumpRule(BumpRule):
126+
_BREAKING_CHANGE_TYPES = set(["BREAKING CHANGE", "BREAKING-CHANGE"])
127+
_MINOR_CHANGE_TYPES = set(["feat"])
126128
_PATCH_CHANGE_TYPES = set(["fix", "perf", "refactor"])
127-
_BREAKING_CHANGE = r"BREAKING[\-\ ]CHANGE"
128-
_RE_BREAKING_CHANGE = re.compile(_BREAKING_CHANGE)
129129

130130
def get_increment(
131131
self, commit_message: str, major_version_zero: bool
@@ -134,12 +134,12 @@ def get_increment(
134134
return None
135135

136136
change_type = m.group("change_type")
137-
if m.group("bang") or self._RE_BREAKING_CHANGE.match(change_type):
137+
if m.group("bang") or change_type in self._BREAKING_CHANGE_TYPES:
138138
return (
139139
SemVerIncrement.MINOR if major_version_zero else SemVerIncrement.MAJOR
140140
)
141141

142-
if change_type == "feat":
142+
if change_type in self._MINOR_CHANGE_TYPES:
143143
return SemVerIncrement.MINOR
144144

145145
if change_type in self._PATCH_CHANGE_TYPES:
@@ -150,13 +150,11 @@ def get_increment(
150150
@cached_property
151151
def _head_pattern(self) -> re.Pattern:
152152
change_types = [
153-
self._BREAKING_CHANGE,
154-
"fix",
155-
"feat",
153+
*self._BREAKING_CHANGE_TYPES,
154+
*self._PATCH_CHANGE_TYPES,
155+
*self._MINOR_CHANGE_TYPES,
156156
"docs",
157157
"style",
158-
"refactor",
159-
"perf",
160158
"test",
161159
"build",
162160
"ci",

0 commit comments

Comments
 (0)