Skip to content

Commit 3f85e7a

Browse files
fix tests
1 parent ff0abdd commit 3f85e7a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_git_commit_timestamp(
9797
list: commit dates in unix timestamp, starts with the most recent commit.
9898
"""
9999

100-
commit_timestamp = None
100+
commit_timestamp = ""
101101

102102
# perform git log operation
103103
try:
@@ -107,13 +107,13 @@ def get_git_commit_timestamp(
107107
realpath = os.path.realpath(path)
108108
git = self._get_repo(realpath)
109109
if is_first_commit:
110-
commit_timestamp = int(git.log(
110+
commit_timestamp = git.log(
111111
realpath, date="short", format="%at", diff_filter="A"
112-
))
112+
)
113113
else:
114-
commit_timestamp = int(git.log(
114+
commit_timestamp = git.log(
115115
realpath, date="short", format="%at", n=1
116-
))
116+
)
117117
except (InvalidGitRepositoryError, NoSuchPathError) as err:
118118
if fallback_to_build_date:
119119
logger.warning(
@@ -154,15 +154,15 @@ def get_git_commit_timestamp(
154154
raise err
155155

156156
# create timestamp
157-
if commit_timestamp is None:
158-
commit_timestamp = int(time.time())
157+
if commit_timestamp == "":
158+
commit_timestamp = time.time()
159159
if not self.fallback_enabled:
160160
logger.warning(
161161
"[git-revision-date-localized-plugin] '%s' has no git logs, using current timestamp"
162162
% path
163163
)
164164

165-
return commit_timestamp
165+
return int(commit_timestamp)
166166

167167
def get_revision_date_for_file(
168168
self,

tests/test_builds.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,12 @@ def validate_build(testproject_path, plugin_config: dict = {}):
195195

196196
repo = Util(str(testproject_path / "docs"))
197197
date_formats = repo.get_revision_date_for_file(
198-
path=str(testproject_path / "docs/page_with_tag.md"),
198+
commit_timestamp=repo.get_git_commit_timestamp(
199+
path=str(testproject_path / "docs/page_with_tag.md"),
200+
is_first_commit=False,
201+
fallback_to_build_date=plugin_config.get("fallback_to_build_date"),
202+
),
199203
locale=plugin_config.get("locale"), # type: ignore
200-
fallback_to_build_date=plugin_config.get("fallback_to_build_date"), # type: ignore
201204
)
202205

203206
searches = [x in contents for x in date_formats.values()]

0 commit comments

Comments
 (0)