Skip to content

Commit

Permalink
fix(bump): only get and validate commits if increment is not provided
Browse files Browse the repository at this point in the history
This avoids calls to git and additional validations that are not necessary when using --increment
  • Loading branch information
chadrik authored and woile committed Feb 26, 2024
1 parent 1059556 commit c245b14
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,10 @@ def __call__(self) -> None: # noqa: C901
scheme=self.scheme,
)

is_initial = self.is_initial_tag(current_tag_version, is_yes)
if is_initial:
commits = git.get_commits()
else:
commits = git.get_commits(current_tag_version)

# If user specified changelog_to_stdout, they probably want the
# changelog to be generated as well, this is the most intuitive solution
self.changelog = self.changelog or bool(self.changelog_to_stdout)

# No commits, there is no need to create an empty tag.
# Unless we previously had a prerelease.
if not commits and not current_version.is_prerelease:
raise NoCommitsFoundError("[NO_COMMITS_FOUND]\n" "No new commits found.")

if manual_version:
try:
new_version = self.scheme(manual_version)
Expand All @@ -234,6 +223,19 @@ def __call__(self) -> None: # noqa: C901
) from exc
else:
if increment is None:
is_initial = self.is_initial_tag(current_tag_version, is_yes)
if is_initial:
commits = git.get_commits()
else:
commits = git.get_commits(current_tag_version)

# No commits, there is no need to create an empty tag.
# Unless we previously had a prerelease.
if not commits and not current_version.is_prerelease:
raise NoCommitsFoundError(
"[NO_COMMITS_FOUND]\n" "No new commits found."
)

increment = self.find_increment(commits)

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

0 comments on commit c245b14

Please sign in to comment.