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

Method __call__

commitizen/commands/version.py:52–157  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

50 self.arguments = arguments
51
52 def __call__(self) -> None:
53 if self.arguments.get("report"):
54 out.write(f"Commitizen Version: {__version__}")
55 out.write(f"Python Version: {sys.version}")
56 out.write(f"Operating System: {platform.system()}")
57 return
58
59 if self.arguments.get("verbose"):
60 out.write(f"Installed Commitizen Version: {__version__}")
61
62 if self.arguments.get("commitizen"):
63 out.write(__version__)
64 return
65
66 if (
67 self.arguments.get("project")
68 or self.arguments.get("verbose")
69 or self.arguments.get("next")
70 or self.arguments.get("manual_version")
71 ):
72 # TODO: once `cz --version` is implemented, move `self.cz` back to __init__
73 self.cz = factory.committer_factory(self.config)
74
75 version_str = self.arguments.get("manual_version")
76 if version_str is None:
77 try:
78 version_str = get_provider(self.config).get_version()
79 except NoVersionSpecifiedError:
80 out.error("No project information in this project.")
81 return
82 try:
83 scheme_factory = get_version_scheme(self.config.settings)
84 except VersionSchemeUnknown:
85 out.error("Unknown version scheme.")
86 return
87
88 try:
89 version = scheme_factory(version_str)
90 except InvalidVersion:
91 out.error(f"Invalid version: '{version_str}'")
92 return
93
94 if next_increment_str := self.arguments.get("next"):
95 if next_increment_str == "USE_GIT_COMMITS":
96 # Only check under `git` to allow the user to do stuff like
97 # `cz version 1.2.3 --major`
98 if not git.is_git_project():
99 raise NotAGitProjectError()
100
101 # TODO: implement USE_GIT_COMMITS by deriving the increment from
102 # git history. This requires refactoring the bump logic out of
103 # `commitizen/commands/bump.py` so it can be reused here. See #1678.
104 version = self._get_next_git_version(version)
105
106 next_increment = VersionIncrement.from_value(next_increment_str)
107 increment: Increment | None
108 if next_increment == VersionIncrement.NONE:
109 increment = None

Callers

nothing calls this directly

Calls 10

_get_next_git_versionMethod · 0.95
get_providerFunction · 0.90
get_version_schemeFunction · 0.90
NotAGitProjectErrorClass · 0.90
from_valueMethod · 0.80
from_settingsMethod · 0.80
normalize_tagMethod · 0.80
getMethod · 0.45
get_versionMethod · 0.45
bumpMethod · 0.45

Tested by

no test coverage detected