File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,14 +90,21 @@ def from_message(
9090 This method preserves that behavior while returning a comparable enum.
9191 """
9292 select_pattern = cls ._compile_pattern (regex )
93- increments = []
93+ increment = cls . NONE
9494
9595 for line in message .split ("\n " ):
9696 result = select_pattern .search (line )
97- if result :
98- increments . append ( cls . from_match ( result . group ( 1 ), increments_map ))
97+ if not result :
98+ continue
9999
100- return max (increments , default = cls .NONE )
100+ increment = max (
101+ increment ,
102+ cls .from_match (result .group (1 ), increments_map ),
103+ )
104+ if increment == cls .MAJOR :
105+ return increment
106+
107+ return increment
101108
102109 @classmethod
103110 def get_highest_by_messages (
Original file line number Diff line number Diff line change @@ -222,6 +222,19 @@ def test_get_highest_by_messages_supports_custom_none_mapping() -> None:
222222
223223
224224
225+ def test_from_message_stops_after_major_match () -> None :
226+ """A major match on one line shields later invalid lines in that message."""
227+ assert (
228+ VersionIncrement .from_message (
229+ "break: api\n \n oops: typo" ,
230+ r"^(break|oops)" ,
231+ {"break" : "MAJOR" , "oops" : "MINORR" },
232+ )
233+ == VersionIncrement .MAJOR
234+ )
235+
236+
237+
225238def test_get_highest_by_messages_raises_for_invalid_bump_map_value () -> None :
226239 """A matched custom bump-map value must fail instead of becoming NONE."""
227240 with pytest .raises (ValueError , match = "MINORR" ):
You can’t perform that action at this time.
0 commit comments