Skip to content

Commit

Permalink
feat: option for excluding renames and move operations for last updat…
Browse files Browse the repository at this point in the history
…e date
  • Loading branch information
skywarth committed Sep 27, 2024
1 parent 3f39e65 commit 466e577
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mkdocs_git_revision_date_localized_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
9 changes: 8 additions & 1 deletion src/mkdocs_git_revision_date_localized_plugin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down

0 comments on commit 466e577

Please sign in to comment.