Skip to content

Commit 7a470bb

Browse files
authored
Merge pull request #398 from lobotmcj/397-changelog-excludes-signed-commits-when-git-config-log-showsignature-true
fix(git.py): ensure signed commits in changelog when git config log.s…
2 parents bec20eb + 184c439 commit 7a470bb

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

commitizen/git.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def get_commits(
7777
args: str = "",
7878
) -> List[GitCommit]:
7979
"""Get the commits between start and end."""
80-
git_log_cmd = f"git log --pretty={log_format}{delimiter} {args}"
80+
git_log_cmd = (
81+
f"git -c log.showSignature=False log --pretty={log_format}{delimiter} {args}"
82+
)
8183

8284
if start:
8385
c = cmd.run(f"{git_log_cmd} {start}..{end}")

tests/test_git.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import inspect
2+
import shutil
23
from typing import List, Optional
34

45
import pytest
@@ -137,6 +138,27 @@ def test_get_commits_without_breakline_in_each_commit(mocker):
137138
)
138139

139140

141+
def test_get_commits_with_signature():
142+
config_file = ".git/config"
143+
config_backup = ".git/config.bak"
144+
shutil.copy(config_file, config_backup)
145+
146+
try:
147+
# temporarily turn on --show-signature
148+
cmd.run("git config log.showsignature true")
149+
150+
# retrieve a commit that we know has a signature
151+
commit = git.get_commits(
152+
start="bec20ebf433f2281c70f1eb4b0b6a1d0ed83e9b2",
153+
end="9eae518235d051f145807ddf971ceb79ad49953a",
154+
)[0]
155+
156+
assert commit.title.startswith("fix")
157+
finally:
158+
# restore the repo's original config
159+
shutil.move(config_backup, config_file)
160+
161+
140162
def test_get_tag_names_has_correct_arrow_annotation():
141163
arrow_annotation = inspect.getfullargspec(git.get_tag_names).annotations["return"]
142164

0 commit comments

Comments
 (0)