@@ -160,10 +160,15 @@ def setup_commit_history(testproject_path):
160160 repo .git .commit (message = "add homepage" , author = author , date = "1500854705" ) # Mon Jul 24 2017 00:05:05 GMT+0000
161161
162162 file_name = os .path .join (testproject_path , "docs/page_with_tag.md" )
163+ with open (file_name , "a" ) as the_file :
164+ the_file .write ("test\n " )
165+ repo .git .add ("docs/page_with_tag.md" )
166+ repo .git .commit (message = "update homepage #1" , author = author , date = "1525475836" ) # Fri May 04 2018 23:17:16 GMT+0000
167+
163168 with open (file_name , "a" ) as the_file :
164169 the_file .write ("awa\n " )
165170 repo .git .add ("docs/page_with_tag.md" )
166- repo .git .commit (message = "update homepage" , author = author , date = "1642911026" ) # Sun Jan 23 2022 04:10:26 GMT+0000
171+ repo .git .commit (message = "update homepage #2 " , author = author , date = "1642911026" ) # Sun Jan 23 2022 04:10:26 GMT+0000
167172
168173 if os .path .exists ("docs/page_with_renamed.md" ):
169174 bf_file_name = os .path .join (testproject_path , "docs/page_with_renamed.md" )
@@ -249,7 +254,7 @@ def validate_build(testproject_path, plugin_config: dict = {}):
249254 contents = page_with_tag .read_text (encoding = "utf8" )
250255 assert re .search (r"renders as\:\s[<span>|\w].+" , contents )
251256
252- repo = Util (config = plugin_config )
257+ repo = Util (config = plugin_config , mkdocs_dir = testproject_path )
253258 date_formats = repo .get_date_formats_for_timestamp (
254259 commit_timestamp = repo .get_git_commit_timestamp (
255260 path = str (testproject_path / "docs/page_with_tag.md" ),
@@ -373,10 +378,10 @@ def test_tags_are_replaced(tmp_path, mkdocs_file):
373378 pytest .skip ("Not necessary to test the JS library" )
374379
375380 # Make sure count_commits() works
376- # We created 10 commits in setup_commit_history()
381+ # We created 11 commits in setup_commit_history()
377382 with working_directory (testproject_path ):
378- u = Util ()
379- assert commit_count (u ._get_repo ("docs/page_with_tag.md" )) == 10
383+ u = Util (config = {}, mkdocs_dir = os . getcwd () )
384+ assert commit_count (u ._get_repo ("docs/page_with_tag.md" )) == 11
380385
381386
382387 # the revision date was in 'setup_commit_history' was set to 1642911026 (Sun Jan 23 2022 04:10:26 GMT+0000)
@@ -667,3 +672,37 @@ def test_mkdocs_genfiles_plugin(tmp_path):
667672 validate_build (
668673 testproject_path , plugin_config
669674 )
675+
676+
677+ def test_ignored_commits (tmp_path ):
678+ testproject_path = setup_clean_mkdocs_folder (
679+ "tests/fixtures/basic_project/mkdocs_ignored_commits.yml" , tmp_path
680+ )
681+ repo = setup_commit_history (testproject_path )
682+
683+ # First test that the middle commit doesn't show up by default
684+ # January 23, 2022 is the date of the most recent commit
685+ with open (str (testproject_path / "ignored-commits.txt" ), "wt" , encoding = "utf-8" ) as fp :
686+ fp .write ("" )
687+
688+ result = build_docs_setup (testproject_path )
689+ assert result .exit_code == 0
690+
691+ page_with_tag = testproject_path / "site/page_with_tag/index.html"
692+ contents = page_with_tag .read_text (encoding = "utf8" )
693+ assert "January 23, 2022" in contents
694+
695+ # Now mark the most recent change to page_with_tag as ignored
696+ # May 4, 2018 is the date of the second most recent commit
697+ commit_hash = repo .git .log ("docs/page_with_tag.md" , format = "%H" , n = 1 )
698+
699+ with open (str (testproject_path / "ignored-commits.txt" ), "wt" , encoding = "utf-8" ) as fp :
700+ fp .write (commit_hash )
701+
702+ # should not raise warning
703+ result = build_docs_setup (testproject_path )
704+ assert result .exit_code == 0
705+
706+ page_with_tag = testproject_path / "site/page_with_tag/index.html"
707+ contents = page_with_tag .read_text (encoding = "utf8" )
708+ assert "May 4, 2018" in contents
0 commit comments