MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / _find_increment

Method _find_increment

commitizen/commands/bump.py:148–173  ·  view source on GitHub ↗

Determine the highest configured increment across candidate commits.

(self, commits: list[git.GitCommit])

Source from the content-addressed store, hash-verified

146 return bool(questionary.confirm("Is this the first tag created?").ask())
147
148 def _find_increment(self, commits: list[git.GitCommit]) -> Increment | None:
149 """Determine the highest configured increment across candidate commits."""
150 # Update the bump map to ensure major version doesn't increment.
151 bump_map = (
152 self.cz.bump_map_major_version_zero
153 if self.bump_settings["major_version_zero"]
154 else self.cz.bump_map
155 )
156 bump_pattern = self.cz.bump_pattern
157
158 if not bump_map or not bump_pattern:
159 raise NoPatternMapError(
160 f"'{self.config.settings['name']}' rule does not support bump"
161 )
162
163 commit_messages = (
164 commit.message for commit in self.cz.filter_commits_before_bump(commits)
165 )
166 increment = VersionIncrement.get_highest_by_messages(
167 commit_messages,
168 bump_pattern,
169 bump_map,
170 )
171 if increment == VersionIncrement.NONE:
172 return None
173 return cast("Increment", str(increment))
174
175 def _validate_arguments(self, current_version: VersionProtocol) -> None:
176 errors: list[str] = []

Callers 1

Calls 3

NoPatternMapErrorClass · 0.90

Tested by

no test coverage detected