Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,7 @@ def __call__(self) -> None:
) from exc
else:
if increment is None:
if current_tag:
commits = git.get_commits(current_tag.name)
else:
commits = git.get_commits()
commits = git.get_commits(current_tag.name if current_tag else None)

# No commits, there is no need to create an empty tag.
# Unless we previously had a prerelease.
Expand Down
2 changes: 1 addition & 1 deletion commitizen/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _get_commits(self) -> list[git.GitCommit]:
return [git.GitCommit(rev="", title="", body=self._filter_comments(msg))]

# Get commit messages from git log (--rev-range)
return git.get_commits(end=self.rev_range or "HEAD")
return git.get_commits(end=self.rev_range)

@staticmethod
def _filter_comments(msg: str) -> str:
Expand Down
7 changes: 5 additions & 2 deletions commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,18 @@ def _create_commit_cmd_string(args: str, committer_date: str | None, name: str)

def get_commits(
start: str | None = None,
end: str = "HEAD",
end: str | None = None,
*,
args: str = "",
) -> list[GitCommit]:
"""Get the commits between start and end."""
if end is None:
end = "HEAD"
git_log_entries = _get_log_as_str_list(start, end, args)
return [
GitCommit.from_rev_and_commit(rev_and_commit)
for rev_and_commit in filter(None, git_log_entries)
for rev_and_commit in git_log_entries
if rev_and_commit
]


Expand Down