(self)
| 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 |
nothing calls this directly
no test coverage detected