From 9c49a846b20a0ff70b39a24b3c937597a351726d Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Thu, 1 Feb 2024 09:48:39 +0100 Subject: [PATCH] fix: add `-c log.showsignature=false` to all `git log` commands if git version is >= 2.10.0 Signed-off-by: Patrick Decat --- dunamai/__init__.py | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/dunamai/__init__.py b/dunamai/__init__.py index 0e0a1c5..530a5a7 100644 --- a/dunamai/__init__.py +++ b/dunamai/__init__.py @@ -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) + ) + 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) @@ -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 @@ -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)