Skip to content

Commit f4cbc35

Browse files
committed
fix(bump): replace all occurances that match regex
1 parent 5b3c9e2 commit f4cbc35

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

commitizen/bump.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,17 @@ def update_version_in_files(
157157
with open(filepath, "r") as f:
158158
version_file = f.read()
159159

160-
match = regex and re.search(regex, version_file, re.MULTILINE)
161-
if match:
162-
left = version_file[: match.end()]
163-
right = version_file[match.end() :]
164-
line_break = _get_line_break_position(right)
165-
middle = right[:line_break]
166-
current_version_found = current_version in middle
167-
right = right[line_break:]
168-
version_file = left + middle.replace(current_version, new_version) + right
160+
if regex:
161+
for match in re.finditer(regex, version_file, re.MULTILINE):
162+
left = version_file[: match.end()]
163+
right = version_file[match.end() :]
164+
line_break = _get_line_break_position(right)
165+
middle = right[:line_break]
166+
current_version_found = current_version in middle
167+
right = right[line_break:]
168+
version_file = (
169+
left + middle.replace(current_version, new_version) + right
170+
)
169171

170172
if not regex:
171173
current_version_regex = _version_to_regex(current_version)

0 commit comments

Comments
 (0)