Skip to content

Commit

Permalink
Merge pull request #398 from lobotmcj/397-changelog-excludes-signed-c…
Browse files Browse the repository at this point in the history
…ommits-when-git-config-log-showsignature-true

fix(git.py): ensure signed commits in changelog when git config log.s…
  • Loading branch information
woile committed Jul 6, 2021
2 parents bec20eb + 184c439 commit 7a470bb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion commitizen/git.py
Expand Up @@ -77,7 +77,9 @@ def get_commits(
args: str = "",
) -> List[GitCommit]:
"""Get the commits between start and end."""
git_log_cmd = f"git log --pretty={log_format}{delimiter} {args}"
git_log_cmd = (
f"git -c log.showSignature=False log --pretty={log_format}{delimiter} {args}"
)

if start:
c = cmd.run(f"{git_log_cmd} {start}..{end}")
Expand Down
22 changes: 22 additions & 0 deletions tests/test_git.py
@@ -1,4 +1,5 @@
import inspect
import shutil
from typing import List, Optional

import pytest
Expand Down Expand Up @@ -137,6 +138,27 @@ def test_get_commits_without_breakline_in_each_commit(mocker):
)


def test_get_commits_with_signature():
config_file = ".git/config"
config_backup = ".git/config.bak"
shutil.copy(config_file, config_backup)

try:
# temporarily turn on --show-signature
cmd.run("git config log.showsignature true")

# retrieve a commit that we know has a signature
commit = git.get_commits(
start="bec20ebf433f2281c70f1eb4b0b6a1d0ed83e9b2",
end="9eae518235d051f145807ddf971ceb79ad49953a",
)[0]

assert commit.title.startswith("fix")
finally:
# restore the repo's original config
shutil.move(config_backup, config_file)


def test_get_tag_names_has_correct_arrow_annotation():
arrow_annotation = inspect.getfullargspec(git.get_tag_names).annotations["return"]

Expand Down

0 comments on commit 7a470bb

Please sign in to comment.