From e9500345bcc0ad0d85e7063a523ac92108afc14f Mon Sep 17 00:00:00 2001 From: Yuhao Zhang Date: Thu, 23 Jun 2022 17:13:47 -0700 Subject: [PATCH] Attempt to extract date from only the last line of git log output Previously, the code assumes the output of `git log --format="%at"` only contains commit timestamp. But this is not true. `--format` only controls a portion of the output. `git log` command can output additional information thats not controlled by format. e.g.: When `showSignature` is set, it will always display commit signature info. This commit attempts to locate timestamps only from the very last line of `git log` output. --- mkdocs_rss_plugin/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs_rss_plugin/util.py b/mkdocs_rss_plugin/util.py index 426c7ce..3c63b04 100644 --- a/mkdocs_rss_plugin/util.py +++ b/mkdocs_rss_plugin/util.py @@ -257,14 +257,14 @@ def get_file_dates( date="short", format="%at", diff_filter="AR", - ) + ).split("\n")[-1] if not dt_updated: dt_updated = self.repo.log( in_page.file.abs_src_path, n=1, date="short", format="%at", - ) + ).split("\n")[-1] except GitCommandError as err: logging.warning( f"Unable to read git logs of '{in_page.file.abs_src_path}'. "