Skip to content

Commit 85683b8

Browse files
committed
refactor(git): retype get_commits parameter to make it more friendly to call sites
1 parent ac9e742 commit 85683b8

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
@@ -253,10 +253,7 @@ def __call__(self) -> None:
253253
) from exc
254254
else:
255255
if increment is None:
256-
if current_tag:
257-
commits = git.get_commits(current_tag.name)
258-
else:
259-
commits = git.get_commits()
256+
commits = git.get_commits(current_tag.name if current_tag else None)
260257

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

commitizen/commands/check.py

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

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

115115
@staticmethod
116116
def _filter_comments(msg: str) -> str:

commitizen/git.py

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

204204
def get_commits(
205205
start: str | None = None,
206-
end: str = "HEAD",
206+
end: str | None = None,
207207
*,
208208
args: str = "",
209209
) -> list[GitCommit]:
210210
"""Get the commits between start and end."""
211+
if end is None:
212+
end = "HEAD"
211213
git_log_entries = _get_log_as_str_list(start, end, args)
212214
return [
213215
GitCommit.from_rev_and_commit(rev_and_commit)
214-
for rev_and_commit in filter(None, git_log_entries)
216+
for rev_and_commit in git_log_entries
217+
if rev_and_commit
215218
]
216219

217220

0 commit comments

Comments
 (0)