Skip to content

Commit cf2876f

Browse files
committed
Renaming option from ignore_missing_git to fallback_to_build_date
1 parent 2392490 commit cf2876f

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Specify a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_co
8787
- When used in combination with `type: timeago` then [timeago.js](https://github.com/hustcc/timeago.js) is added to your website, which supports [these locales](https://github.com/hustcc/timeago.js/tree/master/src/lang). If you specify a locale not supported by timeago.js, the fallback is English (`en`)
8888
- When not set, this plugin will look for `locale` or `language` options set in your theme. If also not set, the fallback is English (`en`)
8989

90-
### `ignore_missing_git`
90+
### `fallback_to_build_date`
9191

9292
If you need to ignore the Git exceptions during `git log` operations, set this option to `true` (default is `false`).
9393

@@ -105,7 +105,7 @@ plugins:
105105
- git-revision-date-localized:
106106
locale: en
107107
type: timeago
108-
ignore_missing_git: true
108+
fallback_to_build_date: true
109109
```
110110

111111
Result:

mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class GitRevisionDateLocalizedPlugin(BasePlugin):
1414
config_scheme = (
15-
("ignore_missing_git", config_options.Type(bool, default=False)),
15+
("fallback_to_build_date", config_options.Type(bool, default=False)),
1616
("locale", config_options.Type(str, default="")),
1717
("type", config_options.Type(str, default="date")),
1818
)
@@ -119,7 +119,7 @@ def on_page_markdown(
119119
revision_dates = self.util.get_revision_date_for_file(
120120
path=page.file.abs_src_path,
121121
locale=self.locale,
122-
ignore_missing_git=self.config.get("ignore_missing_git"),
122+
fallback_to_build_date=self.config.get("fallback_to_build_date"),
123123
)
124124
revision_date = revision_dates[self.config["type"]]
125125
page.meta["git_revision_date_localized"] = revision_date

mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _date_formats(unix_timestamp: float, locale="en") -> dict:
6969
}
7070

7171
def get_revision_date_for_file(
72-
self, path: str, locale: str = "en", ignore_missing_git: bool = False
72+
self, path: str, locale: str = "en", fallback_to_build_date: bool = False
7373
) -> dict:
7474
"""
7575
Determine localized date variants for a given file
@@ -85,7 +85,7 @@ def get_revision_date_for_file(
8585
try:
8686
unix_timestamp = self.repo.log(path, n=1, date="short", format="%at")
8787
except GitCommandError as err:
88-
if ignore_missing_git:
88+
if fallback_to_build_date:
8989
unix_timestamp = None
9090
logging.warning(
9191
"Unable to read git logs of '%s'."
@@ -100,7 +100,7 @@ def get_revision_date_for_file(
100100
)
101101
raise err
102102
except GitCommandNotFound as err:
103-
if ignore_missing_git:
103+
if fallback_to_build_date:
104104
unix_timestamp = None
105105
logging.warning(
106106
"Unable to perform command: git log. Is git installed?"

tests/basic_setup/mkdocs_ignore_missing_git.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ use_directory_urls: true
44
plugins:
55
- search
66
- git-revision-date-localized:
7-
ignore_missing_git: true
7+
fallback_to_build_date: true

tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def test_missing_git_repo_ignored(tmp_path):
222222
When there is no GIT repo, the git error should be ignored.
223223
"""
224224
testproject_path = setup_clean_mkdocs_folder(
225-
mkdocs_yml_path="tests/basic_setup/mkdocs_ignore_missing_git.yml",
225+
mkdocs_yml_path="tests/basic_setup/mkdocs_fallback_to_build_date.yml",
226226
output_path=tmp_path,
227227
)
228228

0 commit comments

Comments
 (0)