@@ -177,7 +177,7 @@ def build_docs_setup(testproject_path):
177
177
raise
178
178
179
179
180
- def validate_build (testproject_path , plugin_config : dict ):
180
+ def validate_build (testproject_path , plugin_config : dict = {} ):
181
181
"""
182
182
Validates a build from a testproject
183
183
@@ -196,7 +196,7 @@ def validate_build(testproject_path, plugin_config: dict):
196
196
contents = page_with_tag .read_text (encoding = "utf8" )
197
197
assert re .search (r"Markdown tag\:\s[<span>|\w].+" , contents )
198
198
199
- repo = Util (str (testproject_path ))
199
+ repo = Util (str (testproject_path / "docs" ))
200
200
date_formats = repo .get_revision_date_for_file (
201
201
path = str (testproject_path / "docs/page_with_tag.md" ),
202
202
locale = plugin_config .get ("locale" ),
@@ -231,9 +231,11 @@ def validate_mkdocs_file(temp_path: str, mkdocs_yml_file: str):
231
231
return testproject_path
232
232
233
233
234
- # #############################################################################
234
+ # ##################################
235
235
# ########### Tests ################
236
236
# ##################################
237
+
238
+
237
239
def test_date_formats ():
238
240
u = Util ()
239
241
assert u ._date_formats (1582397529 ) == {
@@ -321,6 +323,44 @@ def test_type_unknown(tmp_path):
321
323
validate_mkdocs_file (tmp_path , "tests/basic_setup/mkdocs_unknown_type.yml" )
322
324
323
325
326
+ def test_git_in_docs_dir (tmp_path ):
327
+ """
328
+ In https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/pull/31
329
+ a use case is described where `.git` dir lives in `docs/`
330
+ """
331
+
332
+ testproject_path = setup_clean_mkdocs_folder (
333
+ "tests/basic_setup/mkdocs.yml" , tmp_path
334
+ )
335
+
336
+ # Setup git repo in the 'docs' dir
337
+ testproject_docs = str (testproject_path / "docs" )
338
+ repo = git .Repo .init (testproject_docs , bare = False )
339
+ author = "Test Person <[email protected] >"
340
+
341
+ # Change the working directory
342
+ cwd = os .getcwd ()
343
+ os .chdir (testproject_docs )
344
+
345
+ try :
346
+ repo .git .add ("page_with_tag.md" )
347
+ repo .git .commit (message = "homepage" , author = author )
348
+ os .chdir (cwd )
349
+ except :
350
+ os .chdir (cwd )
351
+ raise
352
+
353
+ # Build project
354
+ result = build_docs_setup (testproject_path )
355
+ assert result .exit_code == 0
356
+ validate_build (
357
+ testproject_path ,
358
+ plugin_config = get_plugin_config_from_mkdocs (
359
+ str (testproject_path / "mkdocs.yml" )
360
+ ),
361
+ )
362
+
363
+
324
364
def test_low_fetch_depth (tmp_path , caplog ):
325
365
"""
326
366
On gitlab and github runners, a GIT might have a low fetch
0 commit comments