Skip to content

Commit 484f1f3

Browse files
committed
refactor(git): retype get_commits parameter to make it more friendly to call sites
1 parent ec97453 commit 484f1f3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

commitizen/commands/bump.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,7 @@ def __call__(self) -> None: # noqa: C901
239239
) from exc
240240
else:
241241
if increment is None:
242-
if current_tag:
243-
commits = git.get_commits(current_tag.name)
244-
else:
245-
commits = git.get_commits()
242+
commits = git.get_commits(current_tag.name if current_tag else None)
246243

247244
# No commits, there is no need to create an empty tag.
248245
# Unless we previously had a prerelease.

commitizen/commands/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _get_commits(self):
102102
return [git.GitCommit(rev="", title="", body=self._filter_comments(msg))]
103103

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

107107
@staticmethod
108108
def _filter_comments(msg: str) -> str:

commitizen/git.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,18 @@ def _create_commit_cmd_string(args: str, committer_date: str | None, name: str)
199199

200200
def get_commits(
201201
start: str | None = None,
202-
end: str = "HEAD",
202+
end: str | None = None,
203203
*,
204204
args: str = "",
205205
) -> list[GitCommit]:
206206
"""Get the commits between start and end."""
207+
if end is None:
208+
end = "HEAD"
207209
git_log_entries = _get_log_as_str_list(start, end, args)
208210
return [
209211
GitCommit.from_rev_and_commit(rev_and_commit)
210-
for rev_and_commit in filter(None, git_log_entries)
212+
for rev_and_commit in git_log_entries
213+
if rev_and_commit
211214
]
212215

213216

0 commit comments

Comments
 (0)