Skip to content

date detection from "git log" is broken when git client is configured with "--show-signature" #124

@yuha0

Description

@yuha0

I can't build mkdocs sites from repositories where commits are signed and git client is configured to always show commit signature.

The problem seems to be here:

if not dt_created:
dt_created = self.repo.log(
in_page.file.abs_src_path,
n=1,
date="short",
format="%at",
diff_filter="AR",
)
if not dt_updated:
dt_updated = self.repo.log(
in_page.file.abs_src_path,
n=1,
date="short",
format="%at",
)

It assumes that git log -1 --date=short --format="%at"'s output will only contain the timestamp and nothing else, which isn't true.

My gitconfig contains:

[log]
    showSignature = true

Which is equivalent to git log --show-signature ..., and the output will always contain commit signature info:

$ git log --date=short -1 --format="%at"
gpg: Signature made Tue Jun 21 17:19:48 2022 PDT
gpg:                using EDDSA key 90DA57F75A16D8729DBEE227CD67D78AC53D68C5
gpg: Good signature from "Yuhao Zhang <[email protected]>" [ultimate]
1655857188

And the plugin will crash at:

int(dt_created),
int(dt_updated),

Because the whole string cannot be converted to int.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions