From c2d432b741d4cb460e2eaba36a8ac9424d332d79 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Fri, 10 Nov 2023 20:00:29 +0100 Subject: [PATCH 1/2] Correctly check for truthiness of `generated_by` --- mkdocs_git_revision_date_localized_plugin/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs_git_revision_date_localized_plugin/plugin.py b/mkdocs_git_revision_date_localized_plugin/plugin.py index d93f3df..deae924 100644 --- a/mkdocs_git_revision_date_localized_plugin/plugin.py +++ b/mkdocs_git_revision_date_localized_plugin/plugin.py @@ -199,7 +199,7 @@ def on_page_markdown( # Retrieve git commit timestamp # Except for generated pages (f.e. by mkdocs-gen-files plugin) - if hasattr(page.file, "generated_by"): + if getattr(page.file, "generated_by"): last_revision_timestamp = int(time.time()) else: last_revision_timestamp = self.util.get_git_commit_timestamp( @@ -258,7 +258,7 @@ def on_page_markdown( # Retrieve git commit timestamp # Except for generated pages (f.e. by mkdocs-gen-files plugin) - if hasattr(page.file, "generated_by"): + if getattr(page.file, "generated_by"): first_revision_timestamp = int(time.time()) else: first_revision_timestamp = self.util.get_git_commit_timestamp( From c255498daf51b2c32871b8b448cd8af7dd2b6fcb Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Sat, 11 Nov 2023 10:49:58 +0100 Subject: [PATCH 2/2] Make the check actually safe --- mkdocs_git_revision_date_localized_plugin/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs_git_revision_date_localized_plugin/plugin.py b/mkdocs_git_revision_date_localized_plugin/plugin.py index deae924..59eeefb 100644 --- a/mkdocs_git_revision_date_localized_plugin/plugin.py +++ b/mkdocs_git_revision_date_localized_plugin/plugin.py @@ -199,7 +199,7 @@ def on_page_markdown( # Retrieve git commit timestamp # Except for generated pages (f.e. by mkdocs-gen-files plugin) - if getattr(page.file, "generated_by"): + if getattr(page.file, "generated_by", None): last_revision_timestamp = int(time.time()) else: last_revision_timestamp = self.util.get_git_commit_timestamp( @@ -258,7 +258,7 @@ def on_page_markdown( # Retrieve git commit timestamp # Except for generated pages (f.e. by mkdocs-gen-files plugin) - if getattr(page.file, "generated_by"): + if getattr(page.file, "generated_by", None): first_revision_timestamp = int(time.time()) else: first_revision_timestamp = self.util.get_git_commit_timestamp(