@@ -30,16 +30,20 @@ def find_increment(
30
30
increment : str | None = None
31
31
32
32
for commit in commits :
33
- for message in commit . message . split ( " \n " ):
34
- result = select_pattern .search ( message )
35
-
36
- if result :
33
+ for message in filter (
34
+ None , map ( select_pattern .search , commit . message . split ( " \n " ) )
35
+ ):
36
+ if result := select_pattern . search ( message ) :
37
37
found_keyword = result .group (1 )
38
- new_increment = None
39
- for match_pattern in increments_map .keys ():
40
- if re .match (match_pattern , found_keyword ):
41
- new_increment = increments_map [match_pattern ]
42
- break
38
+
39
+ new_increment = next (
40
+ (
41
+ increment_type
42
+ for match_pattern , increment_type in increments_map .items ()
43
+ if re .match (match_pattern , found_keyword )
44
+ ),
45
+ None ,
46
+ )
43
47
44
48
if new_increment is None :
45
49
logger .debug (
@@ -76,7 +80,7 @@ def update_version_in_files(
76
80
"""
77
81
# TODO: separate check step and write step
78
82
updated = []
79
- for path , regex in files_and_regexs (files , current_version ):
83
+ for path , regex in _files_and_regexes (files , current_version ):
80
84
current_version_found , version_file = _bump_with_regex (
81
85
path ,
82
86
current_version ,
@@ -99,7 +103,7 @@ def update_version_in_files(
99
103
return updated
100
104
101
105
102
- def files_and_regexs (patterns : list [str ], version : str ) -> list [tuple [str , str ]]:
106
+ def _files_and_regexes (patterns : list [str ], version : str ) -> list [tuple [str , str ]]:
103
107
"""
104
108
Resolve all distinct files with their regexp from a list of glob patterns with optional regexp
105
109
"""
0 commit comments