Skip to content

Commit c245b14

Browse files
chadrikwoile
authored andcommitted
fix(bump): only get and validate commits if increment is not provided
This avoids calls to git and additional validations that are not necessary when using --increment
1 parent 1059556 commit c245b14

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

commitizen/commands/bump.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,10 @@ def __call__(self) -> None: # noqa: C901
209209
scheme=self.scheme,
210210
)
211211

212-
is_initial = self.is_initial_tag(current_tag_version, is_yes)
213-
if is_initial:
214-
commits = git.get_commits()
215-
else:
216-
commits = git.get_commits(current_tag_version)
217-
218212
# If user specified changelog_to_stdout, they probably want the
219213
# changelog to be generated as well, this is the most intuitive solution
220214
self.changelog = self.changelog or bool(self.changelog_to_stdout)
221215

222-
# No commits, there is no need to create an empty tag.
223-
# Unless we previously had a prerelease.
224-
if not commits and not current_version.is_prerelease:
225-
raise NoCommitsFoundError("[NO_COMMITS_FOUND]\n" "No new commits found.")
226-
227216
if manual_version:
228217
try:
229218
new_version = self.scheme(manual_version)
@@ -234,6 +223,19 @@ def __call__(self) -> None: # noqa: C901
234223
) from exc
235224
else:
236225
if increment is None:
226+
is_initial = self.is_initial_tag(current_tag_version, is_yes)
227+
if is_initial:
228+
commits = git.get_commits()
229+
else:
230+
commits = git.get_commits(current_tag_version)
231+
232+
# No commits, there is no need to create an empty tag.
233+
# Unless we previously had a prerelease.
234+
if not commits and not current_version.is_prerelease:
235+
raise NoCommitsFoundError(
236+
"[NO_COMMITS_FOUND]\n" "No new commits found."
237+
)
238+
237239
increment = self.find_increment(commits)
238240

239241
# It may happen that there are commits, but they are not eligible

0 commit comments

Comments
 (0)