Skip to content

fix(git.py): ensure signed commits in changelog when git config log.s… #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion commitizen/git.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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