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

Method __call__

commitizen/commands/bump.py:253–452  ·  view source on GitHub ↗

Steps executed to bump.

(self)

Source from the content-addressed store, hash-verified

251 )
252
253 def __call__(self) -> None:
254 """Steps executed to bump."""
255 provider = get_provider(self.config)
256 current_version = self.scheme(provider.get_version())
257 self._validate_arguments(current_version)
258
259 next_version_to_stdout = self.arguments["get_next"]
260 if next_version_to_stdout:
261 for value, option in (
262 (self.changelog_flag, "--changelog"),
263 (self.changelog_to_stdout, "--changelog-to-stdout"),
264 ):
265 if value:
266 warnings.warn(f"{option} has no effect when used with --get-next")
267
268 # If user specified changelog_to_stdout, they probably want the
269 # changelog to be generated as well, this is the most intuitive solution
270 self.changelog_flag = any(
271 (
272 self.changelog_flag,
273 self.changelog_to_stdout,
274 self.config.settings.get("update_changelog_on_bump"),
275 )
276 )
277
278 rules = TagRules.from_settings(cast("Settings", self.bump_settings))
279 current_tag = rules.find_tag_for(git.get_tags(), current_version)
280 current_tag_version = (
281 current_tag.name if current_tag else rules.normalize_tag(current_version)
282 )
283
284 is_initial = self._is_initial_tag(current_tag, self.arguments["yes"])
285
286 increment, new_version = self._resolve_increment_and_new_version(
287 current_version, current_tag
288 )
289
290 new_tag_version = rules.normalize_tag(new_version)
291 if next_version_to_stdout:
292 if increment is None and new_tag_version == current_tag_version:
293 raise NoneIncrementExit(
294 "[NO_COMMITS_TO_BUMP]\n"
295 "The commits found are not eligible to be bumped"
296 )
297 out.write(str(new_version))
298 raise DryRunExit()
299
300 message = bump.create_commit_message(
301 current_version, new_version, self.bump_settings["bump_message"]
302 )
303 # Report found information
304 information = f"{message}\ntag to create: {new_tag_version}\n"
305 if increment:
306 information += f"increment detected: {increment}\n"
307
308 if self.changelog_to_stdout:
309 # When the changelog goes to stdout, we want to send
310 # the bump information to stderr, this way the

Callers

nothing calls this directly

Calls 15

_validate_argumentsMethod · 0.95
_is_initial_tagMethod · 0.95
_get_commit_argsMethod · 0.95
get_providerFunction · 0.90
NoneIncrementExitClass · 0.90
DryRunExitClass · 0.90
ChangelogClass · 0.90
ExpectedExitClass · 0.90
BumpTagFailedErrorClass · 0.90
from_settingsMethod · 0.80

Tested by

no test coverage detected