Skip to content

Commit 654f4a0

Browse files
bearomorphismLee-W
authored andcommitted
refactor(git): retype get_commits parameter to make it more friendly to call sites
1 parent af50d85 commit 654f4a0

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
@@ -201,15 +201,18 @@ def _create_commit_cmd_string(args: str, committer_date: str | None, name: str)
201201

202202
def get_commits(
203203
start: str | None = None,
204-
end: str = "HEAD",
204+
end: str | None = None,
205205
*,
206206
args: str = "",
207207
) -> list[GitCommit]:
208208
"""Get the commits between start and end."""
209+
if end is None:
210+
end = "HEAD"
209211
git_log_entries = _get_log_as_str_list(start, end, args)
210212
return [
211213
GitCommit.from_rev_and_commit(rev_and_commit)
212-
for rev_and_commit in filter(None, git_log_entries)
214+
for rev_and_commit in git_log_entries
215+
if rev_and_commit
213216
]
214217

215218

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy