@@ -76,7 +76,7 @@ def update_version_in_files(
7676 """
7777 # TODO: separate check step and write step
7878 updated = []
79- for path , regex in files_and_regexs (files , current_version ):
79+ for path , regex in _files_and_regexes (files , current_version ):
8080 current_version_found , version_file = _bump_with_regex (
8181 path ,
8282 current_version ,
@@ -99,7 +99,7 @@ def update_version_in_files(
9999 return updated
100100
101101
102- def files_and_regexs (patterns : list [str ], version : str ) -> list [tuple [str , str ]]:
102+ def _files_and_regexes (patterns : list [str ], version : str ) -> list [tuple [str , str ]]:
103103 """
104104 Resolve all distinct files with their regexp from a list of glob patterns with optional regexp
105105 """
@@ -128,13 +128,15 @@ def _bump_with_regex(
128128 pattern = re .compile (regex )
129129 with open (version_filepath , encoding = encoding ) as f :
130130 for line in f :
131- if pattern .search (line ):
132- bumped_line = line .replace (current_version , new_version )
133- if bumped_line != line :
134- current_version_found = True
135- lines .append (bumped_line )
136- else :
131+ if not pattern .search (line ):
137132 lines .append (line )
133+ continue
134+
135+ bumped_line = line .replace (current_version , new_version )
136+ if bumped_line != line :
137+ current_version_found = True
138+ lines .append (bumped_line )
139+
138140 return current_version_found , "" .join (lines )
139141
140142
0 commit comments