8000 fix(bump): fix error due to bumping version file without eol through … · jordanSu/commitizen@76b3030 · GitHub
Skip to content

Commit 76b3030

Browse files
committed
fix(bump): fix error due to bumping version file without eol through regex
1 parent fde3b72 commit 76b3030

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

commitizen/bump.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ def _bump_with_regex(version_file_contents, current_version, new_version, regex)
186186
for match in re.finditer(regex, version_file_contents, re.MULTILINE):
187187
left = version_file_contents[: match.end() + offset]
188188
right = version_file_contents[match.end() + offset :]
189-
line_break = _get_line_break_position(right)
189+
190+
line_break = right.find("\n")
190191
middle = right[:line_break]
191192
right = right[line_break:]
193+
192194
if current_version in middle:
193195
offset += len(new_version) - len(current_version)
194196
current_version_found = True
@@ -198,11 +200,6 @@ def _bump_with_regex(version_file_contents, current_version, new_version, regex)
198200
return current_version_found, version_file_contents
199201

200202

201-
def _get_line_break_position(text: str) -> int:
202-
position = text.find("\n")
203-
return max(position, 0)
204-
205-
206203
def _version_to_regex(version: str):
207204
clean_regex = version.replace(".", r"\.").replace("+", r"\+")
208205
return re.compile(f"{clean_regex}")

0 commit comments

Comments
 (0)
0