Skip to content

Commit 466e577

Browse files
committed
feat: option for excluding renames and move operations for last update date
1 parent 3f39e65 commit 466e577

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class GitRevisionDateLocalizedPlugin(BasePlugin):
4343
("enable_creation_date", config_options.Type(bool, default=False)),
4444
("enabled", config_options.Type(bool, default=True)),
4545
("strict", config_options.Type(bool, default=True)),
46+
("last_update_exclude_renames", config_options.Type(bool, default=False))
4647
)
4748

4849
def on_config(self, config: config_options.Config, **kwargs) -> Dict[str, Any]:

src/mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,15 @@ def get_git_commit_timestamp(
9292
commit_timestamp = commit_timestamp.split()[-1]
9393
else:
9494
# Latest commit touching a specific file
95+
if self.config.get('last_update_exclude_renames'):
96+
# We can remove if-else statement and do a one-liner as well
97+
diff_filter_param = "r"
98+
follow_param = True
99+
else:
100+
diff_filter_param = ""
101+
follow_param = False
95102
commit_timestamp = git.log(
96-
realpath, date="unix", format="%at", n=1, no_show_signature=True
103+
realpath, date="unix", format="%at", diff_filter=diff_filter_param, n=1, no_show_signature=True, follow=follow_param
97104
)
98105
except (InvalidGitRepositoryError, NoSuchPathError) as err:
99106
if self.config.get('fallback_to_build_date'):

0 commit comments

Comments
 (0)