Compute the highest increment contributed by one commit message. Commitizen historically evaluates each line of the full commit message against ``bump_pattern`` and then keeps the highest resulting bump. This method preserves that behavior while returning a comparable enum.
(
cls, message: str, regex: RegexPattern, increments_map: Mapping[str, object]
)
| 103 | |
| 104 | @classmethod |
| 105 | def from_message( |
| 106 | cls, message: str, regex: RegexPattern, increments_map: Mapping[str, object] |
| 107 | ) -> VersionIncrement: |
| 108 | """Compute the highest increment contributed by one commit message. |
| 109 | |
| 110 | Commitizen historically evaluates each line of the full commit message |
| 111 | against ``bump_pattern`` and then keeps the highest resulting bump. |
| 112 | This method preserves that behavior while returning a comparable enum. |
| 113 | """ |
| 114 | select_pattern = cls._compile_pattern(regex) |
| 115 | increment = cls.NONE |
| 116 | |
| 117 | for line in message.split("\n"): |
| 118 | result = select_pattern.search(line) |
| 119 | if not result: |
| 120 | continue |
| 121 | |
| 122 | increment = max( |
| 123 | increment, |
| 124 | cls.from_match(result.group(1), increments_map), |
| 125 | ) |
| 126 | if increment == cls.MAJOR: |
| 127 | return increment |
| 128 | |
| 129 | return increment |
| 130 | |
| 131 | @classmethod |
| 132 | def get_highest_by_messages( |