Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c49f6ea

Browse filesBrowse files
committed
refactor(bump): avoid nesting
1 parent 597ccb9 commit c49f6ea
Copy full SHA for c49f6ea

File tree

1 file changed

+8
-6
lines changed
Filter options

1 file changed

+8
-6
lines changed

‎commitizen/bump.py

Copy file name to clipboardExpand all lines: commitizen/bump.py
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,15 @@ def _bump_with_regex(
135135
pattern = re.compile(regex)
136136
with open(version_filepath, encoding=encoding) as f:
137137
for line in f:
138-
if pattern.search(line):
139-
bumped_line = line.replace(current_version, new_version)
140-
if bumped_line != line:
141-
current_version_found = True
142-
lines.append(bumped_line)
143-
else:
138+
if not pattern.search(line):
144139
lines.append(line)
140+
continue
141+
142+
bumped_line = line.replace(current_version, new_version)
143+
if bumped_line != line:
144+
current_version_found = True
145+
lines.append(bumped_line)
146+
145147
return current_version_found, "".join(lines)
146148

147149

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.