Skip to content

Commit 35d9c05

Browse files
committed
refactor(bump): clean up
1 parent 9420b44 commit 35d9c05

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

commitizen/commands/bump.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,18 @@ def is_initial_tag(
105105
self, current_tag: git.GitTag | None, is_yes: bool = False
106106
) -> bool:
107107
"""Check if reading the whole git tree up to HEAD is needed."""
108-
is_initial = False
109-
if not current_tag:
110-
if is_yes:
111-
is_initial = True
112-
else:
113-
out.info("No tag matching configuration could not be found.")
114-
out.info(
115-
"Possible causes:\n"
116-
"- version in configuration is not the current version\n"
117-
"- tag_format or legacy_tag_formats is missing, check them using 'git tag --list'\n"
118-
)
119-
is_initial = questionary.confirm("Is this the first tag created?").ask()
120-
return is_initial
108+
if current_tag:
109+
return False
110+
if is_yes:
111+
return True
112+
113+
out.info("No tag matching configuration could not be found.")
114+
out.info(
115+
"Possible causes:\n"
116+
"- version in configuration is not the current version\n"
117+
"- tag_format or legacy_tag_formats is missing, check them using 'git tag --list'\n"
118+
)
119+
return bool(questionary.confirm("Is this the first tag created?").ask())
121120

122121
def find_increment(self, commits: list[git.GitCommit]) -> Increment | None:
123122
# Update the bump map to ensure major version doesn't increment.
@@ -134,10 +133,7 @@ def find_increment(self, commits: list[git.GitCommit]) -> Increment | None:
134133
raise NoPatternMapError(
135134
f"'{self.config.settings['name']}' rule does not support bump"
136135
)
137-
increment = bump.find_increment(
138-
commits, regex=bump_pattern, increments_map=bump_map
139-
)
140-
return increment
136+
return bump.find_increment(commits, regex=bump_pattern, increments_map=bump_map)
141137

142138
def __call__(self) -> None: # noqa: C901
143139
"""Steps executed to bump."""
@@ -148,7 +144,7 @@ def __call__(self) -> None: # noqa: C901
148144
except TypeError:
149145
raise NoVersionSpecifiedError()
150146

151-
bump_commit_message: str = self.bump_settings["bump_message"]
147+
bump_commit_message: str | None = self.bump_settings["bump_message"]
152148
version_files: list[str] = self.bump_settings["version_files"]
153149
major_version_zero: bool = self.bump_settings["major_version_zero"]
154150
prerelease_offset: int = self.bump_settings["prerelease_offset"]

0 commit comments

Comments
 (0)