Skip to content
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

fix: add -c log.showsignature=false to all git log commands #75

Merged
merged 1 commit into from
Feb 6, 2024
Merged
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
42 changes: 30 additions & 12 deletions dunamai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,16 @@ def normalize_tag_ref(ref: str) -> str:
def from_git_tag_topo_order(
tag_branch: str, git_version: List[int], path: Optional[Path]
) -> Mapping[str, int]:
cmd = (
"git log --simplify-by-decoration --topo-order --decorate=full"
' {} "--format=%H%d"'.format(tag_branch)
)
if git_version < [2, 10]:
cmd = (
"git log --simplify-by-decoration --topo-order"
' --decorate=full {} "--format=%H%d"'.format(tag_branch)
Comment on lines +484 to +485
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's certainly room to improve this and avoid duplication, but I've seen this pattern used below, so I figured I'd stick to it.

Maybe extracting git log commands into a function would help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A way more intrusive change would be to use something like https://github.com/jelmer/dulwich or https://github.com/gitpython-developers/GitPython to avoid having to deal with such details altogether.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can definitely try to reduce some of the duplication, but I think it's okay for now.

I'd like to keep Dunamai's dependencies pretty minimal; otherwise, yeah, Dulwich or GitPython could be nice.

)
else:
cmd = (
"git -c log.showsignature=false log --simplify-by-decoration --topo-order"
' --decorate=full {} "--format=%H%d"'.format(tag_branch)
)
if git_version >= [2, 16]:
cmd += " --decorate-refs=refs/tags/"
code, logmsg = _run_cmd(cmd, path)
Expand Down Expand Up @@ -1088,11 +1094,20 @@ def from_git(
else:
branch = msg

code, msg = _run_cmd(
'git log -n 1 --format="format:{}"'.format("%H" if full_commit else "%h"),
path,
codes=[0, 128],
)
if git_version < [2, 10]:
code, msg = _run_cmd(
'git log -n 1 --format="format:{}"'.format("%H" if full_commit else "%h"),
path,
codes=[0, 128],
)
else:
code, msg = _run_cmd(
'git -c log.showsignature=false log -n 1 --format="format:{}"'.format(
"%H" if full_commit else "%h"
),
path,
codes=[0, 128],
)
if code == 128:
return cls._fallback(
strict, distance=0, dirty=True, branch=branch, concerns=concerns, vcs=vcs
Expand All @@ -1104,9 +1119,12 @@ def from_git(
code, msg = _run_cmd('git log -n 1 --pretty=format:"%ci"', path)
timestamp = _parse_git_timestamp_iso(msg)
else:
code, msg = _run_cmd(
'git -c log.showsignature=false log -n 1 --pretty=format:"%cI"', path
)
if git_version < [2, 10]:
code, msg = _run_cmd('git log -n 1 --pretty=format:"%cI"', path)
else:
code, msg = _run_cmd(
'git -c log.showsignature=false log -n 1 --pretty=format:"%cI"', path
)
timestamp = _parse_git_timestamp_iso_strict(msg)

code, msg = _run_cmd("git describe --always --dirty", path)
Expand Down
Loading