diff --git a/src/mkdocs_git_revision_date_localized_plugin/plugin.py b/src/mkdocs_git_revision_date_localized_plugin/plugin.py index f0360c9..0f3611e 100644 --- a/src/mkdocs_git_revision_date_localized_plugin/plugin.py +++ b/src/mkdocs_git_revision_date_localized_plugin/plugin.py @@ -43,6 +43,7 @@ class GitRevisionDateLocalizedPlugin(BasePlugin): ("enable_creation_date", config_options.Type(bool, default=False)), ("enabled", config_options.Type(bool, default=True)), ("strict", config_options.Type(bool, default=True)), + ("last_update_exclude_renames", config_options.Type(bool, default=False)) ) def on_config(self, config: config_options.Config, **kwargs) -> Dict[str, Any]: diff --git a/src/mkdocs_git_revision_date_localized_plugin/util.py b/src/mkdocs_git_revision_date_localized_plugin/util.py index 1cbb474..cc8d6d1 100644 --- a/src/mkdocs_git_revision_date_localized_plugin/util.py +++ b/src/mkdocs_git_revision_date_localized_plugin/util.py @@ -92,8 +92,15 @@ def get_git_commit_timestamp( commit_timestamp = commit_timestamp.split()[-1] else: # Latest commit touching a specific file + if self.config.get('last_update_exclude_renames'): + # We can remove if-else statement and do a one-liner as well + diff_filter_param = "r" + follow_param = True + else: + diff_filter_param = "" + follow_param = False commit_timestamp = git.log( - realpath, date="unix", format="%at", n=1, no_show_signature=True + realpath, date="unix", format="%at", diff_filter=diff_filter_param, n=1, no_show_signature=True, follow=follow_param ) except (InvalidGitRepositoryError, NoSuchPathError) as err: if self.config.get('fallback_to_build_date'):