File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
mkdocs_git_revision_date_localized_plugin Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def raise_ci_warnings(repo) -> None:
2020
2121 n_commits = commit_count (repo )
2222
23+
2324 # Gitlab Runners
2425 if os .getenv ("GITLAB_CI" ) is not None and n_commits < 50 :
2526 # Default is GIT_DEPTH of 50 for gitlab
@@ -85,11 +86,7 @@ def commit_count(repo) -> int:
8586 Returns:
8687 count (int): Number of commits.
8788 """
88- refs = repo .for_each_ref ().split ("\n " )
89- refs = [x .split ()[0 ] for x in refs ]
90-
91- counts = [int (repo .rev_list (x , count = True , first_parent = True )) for x in refs ]
92- return max (counts )
89+ return int (repo .rev_list ('--count' ,'HEAD' ))
9390
9491
9592def is_shallow_clone (repo ) -> bool :
Original file line number Diff line number Diff line change 2828
2929# package module
3030from mkdocs_git_revision_date_localized_plugin .util import Util
31+ from mkdocs_git_revision_date_localized_plugin .ci import commit_count
3132
3233# ##################################
3334# ######## Globals #################
@@ -350,7 +351,13 @@ def test_tags_are_replaced(tmp_path, mkdocs_file):
350351
351352 if plugin_config .get ("type" ) == "timeago" :
352353 pytest .skip ("Not necessary to test the JS library" )
353-
354+
355+ # Make sure count_commits() works
356+ # We created 8 commits in setup_commit_history()
357+ with working_directory (testproject_path ):
358+ u = Util ()
359+ assert commit_count (u ._get_repo ("docs/page_with_tag.md" )) == 8
360+
354361
355362 # the revision date was in 'setup_commit_history' was set to 1642911026 (Sun Jan 23 2022 04:10:26 GMT+0000)
356363 # Assert {{ git_revision_date_localized }} is replaced
You can’t perform that action at this time.
0 commit comments