11"""Fail loudly if the committed coverage map is stale or under-covers. Used by coverage-health.yml."""
22import datetime
3- import subprocess
43import sys
54from pathlib import Path
65
76sys .path .insert (0 , str (Path (__file__ ).resolve ().parents [2 ] / "toolchain" ))
8- from mfc .test .coverage import COVERAGE_MAP_PATH , load_map , map_health # noqa: E402
7+ from mfc .test .coverage import COVERAGE_MAP_PATH , _git , load_map , map_health # noqa: E402
98from mfc .test .cases import list_cases # noqa: E402 (returns the current test list)
109
1110MAX_AGE_DAYS = 10
@@ -40,7 +39,7 @@ def verified_sha(cwd=None):
4039 caller must read that as undeterminable and fall back to the wall-clock age rule, not
4140 as a failure -- an absent ref is not evidence of a broken refresh.
4241 """
43- rev = subprocess . run (["git" , " rev-parse" , "--verify" , "--quiet" , f"{ VERIFIED_REF } ^{{commit}}" ], capture_output = True , text = True , check = False , cwd = cwd )
42+ rev = _git (["rev-parse" , "--verify" , "--quiet" , f"{ VERIFIED_REF } ^{{commit}}" ], cwd )
4443 return rev .stdout .strip () or None
4544
4645
@@ -53,10 +52,10 @@ def verified_after_last_change(git_sha, cwd=None):
5352 """
5453 if not git_sha :
5554 return None
56- last = subprocess . run (["git" , " log" , "-1" , "--format=%H" , "--" , * COVERAGE_RELEVANT_PATHS ], capture_output = True , text = True , check = False , cwd = cwd )
55+ last = _git (["log" , "-1" , "--format=%H" , "--" , * COVERAGE_RELEVANT_PATHS ], cwd )
5756 if last .returncode != 0 or not last .stdout .strip ():
5857 return None # shallow clone or no such commit -> fall back to the age rule
59- ancestor = subprocess . run (["git" , " merge-base" , "--is-ancestor" , last .stdout .strip (), git_sha ], capture_output = True , check = False , cwd = cwd )
58+ ancestor = _git (["merge-base" , "--is-ancestor" , last .stdout .strip (), git_sha ], cwd )
6059 return {0 : True , 1 : False }.get (ancestor .returncode ) # anything else -> None (unknown sha, shallow history)
6160
6261
0 commit comments