Skip to content

Commit 255878c

Browse files
committed
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 66896bc commit 255878c

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
@@ -200,21 +200,10 @@ def __call__(self) -> None: # noqa: C901
200200
scheme=self.scheme,
201201
)
202202

203-
is_initial = self.is_initial_tag(current_tag_version, is_yes)
204-
if is_initial:
205-
commits = git.get_commits()
206-
else:
207-
commits = git.get_commits(current_tag_version)
208-
209203
# If user specified changelog_to_stdout, they probably want the
210204
# changelog to be generated as well, this is the most intuitive solution
211205
self.changelog = self.changelog or bool(self.changelog_to_stdout)
212206

213-
# No commits, there is no need to create an empty tag.
214-
# Unless we previously had a prerelease.
215-
if not commits and not current_version.is_prerelease:
216-
raise NoCommitsFoundError("[NO_COMMITS_FOUND]\n" "No new commits found.")
217-
218207
if manual_version:
219208
try:
220209
new_version = self.scheme(manual_version)
@@ -225,6 +214,19 @@ def __call__(self) -> None: # noqa: C901
225214
) from exc
226215
else:
227216
if increment is None:
217+
is_initial = self.is_initial_tag(current_tag_version, is_yes)
218+
if is_initial:
219+
commits = git.get_commits()
220+
else:
221+
commits = git.get_commits(current_tag_version)
222+
223+
# No commits, there is no need to create an empty tag.
224+
# Unless we previously had a prerelease.
225+
if not commits and not current_version.is_prerelease:
226+
raise NoCommitsFoundError(
227+
"[NO_COMMITS_FOUND]\n" "No new commits found."
228+
)
229+
228230
increment = self.find_increment(commits)
229231

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

0 commit comments

Comments
 (0)