Skip to content

Commit f848ea1

Browse files
committed
feat: reverted previous changes about exclude option, new option for follow introduced, added additional parameter for revision changes, diff-filter "r" is added for both creation and revision commit histories
1 parent 466e577 commit f848ea1

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +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))
46+
("version_history_follow_enabled", config_options.Type(bool, default=True))
4747
)
4848

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

src/mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ def get_git_commit_timestamp(
8080
realpath = os.path.realpath(path)
8181
git = self._get_repo(realpath)
8282

83+
follow_option=self.config.get('version_history_follow_enabled')
84+
8385
if is_first_commit:
8486
# diff_filter="A" will select the commit that created the file
8587
commit_timestamp = git.log(
86-
realpath, date="unix", format="%at", diff_filter="A", no_show_signature=True, follow=True
88+
realpath, date="unix", format="%at", diff_filter="Ar", no_show_signature=True, follow=follow_option
8789
)
8890
# A file can be created multiple times, through a file renamed.
8991
# Commits are ordered with most recent commit first
@@ -92,16 +94,12 @@ def get_git_commit_timestamp(
9294
commit_timestamp = commit_timestamp.split()[-1]
9395
else:
9496
# 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
10297
commit_timestamp = git.log(
103-
realpath, date="unix", format="%at", diff_filter=diff_filter_param, n=1, no_show_signature=True, follow=follow_param
98+
realpath, date="unix", format="%at",
99+
diff_filter="r", n=1, no_show_signature=True, follow=follow_option,
100+
ignore_all_space=True, ignore_blank_lines=True
104101
)
102+
105103
except (InvalidGitRepositoryError, NoSuchPathError) as err:
106104
if self.config.get('fallback_to_build_date'):
107105
log(

0 commit comments

Comments
 (0)