Skip to content

Commit fae51f2

Browse files
committed
Name the git helper the coverage health check imports as public
1 parent 9d17dff commit fae51f2

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

.github/scripts/check_coverage_map_health.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "toolchain"))
7-
from mfc.test.coverage import COVERAGE_MAP_PATH, _git, load_map, map_health # noqa: E402
7+
from mfc.test.coverage import COVERAGE_MAP_PATH, load_map, map_health, run_git # noqa: E402
88
from mfc.test.cases import list_cases # noqa: E402 (returns the current test list)
99

1010
MAX_AGE_DAYS = 10
@@ -39,7 +39,7 @@ def verified_sha(cwd=None):
3939
caller must read that as undeterminable and fall back to the wall-clock age rule, not
4040
as a failure -- an absent ref is not evidence of a broken refresh.
4141
"""
42-
rev = _git(["rev-parse", "--verify", "--quiet", f"{VERIFIED_REF}^{{commit}}"], cwd)
42+
rev = run_git(["rev-parse", "--verify", "--quiet", f"{VERIFIED_REF}^{{commit}}"], cwd)
4343
return rev.stdout.strip() or None
4444

4545

@@ -52,10 +52,10 @@ def verified_after_last_change(git_sha, cwd=None):
5252
"""
5353
if not git_sha:
5454
return None
55-
last = _git(["log", "-1", "--format=%H", "--", *COVERAGE_RELEVANT_PATHS], cwd)
55+
last = run_git(["log", "-1", "--format=%H", "--", *COVERAGE_RELEVANT_PATHS], cwd)
5656
if last.returncode != 0 or not last.stdout.strip():
5757
return None # shallow clone or no such commit -> fall back to the age rule
58-
ancestor = _git(["merge-base", "--is-ancestor", last.stdout.strip(), git_sha], cwd)
58+
ancestor = run_git(["merge-base", "--is-ancestor", last.stdout.strip(), git_sha], cwd)
5959
return {0: True, 1: False}.get(ancestor.returncode) # anything else -> None (unknown sha, shallow history)
6060

6161

toolchain/mfc/test/coverage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ def _env_without_git():
222222
return {k: v for k, v in os.environ.items() if not k.startswith("GIT_")}
223223

224224

225-
def _git(args, cwd, timeout=60):
225+
def run_git(args, cwd, timeout=60):
226226
return subprocess.run(["git", *args], capture_output=True, text=True, cwd=cwd, timeout=timeout, check=False, env=_env_without_git())
227227

228228

229229
def _merge_base(cwd, branch):
230230
for ref in (branch, f"origin/{branch}"):
231-
r = _git(["merge-base", ref, "HEAD"], cwd)
231+
r = run_git(["merge-base", ref, "HEAD"], cwd)
232232
if r.returncode == 0 and r.stdout.strip():
233233
return r.stdout.strip()
234234
return None
@@ -252,12 +252,12 @@ def get_changed_files(root_dir, compare_branch="master", explicit: Optional[str]
252252
try:
253253
base = _merge_base(root_dir, compare_branch)
254254
if base is None:
255-
_git(["fetch", "origin", f"{compare_branch}:{compare_branch}", "--depth=1"], root_dir, 120)
256-
_git(["fetch", "--deepen=200"], root_dir, 120)
255+
run_git(["fetch", "origin", f"{compare_branch}:{compare_branch}", "--depth=1"], root_dir, 120)
256+
run_git(["fetch", "--deepen=200"], root_dir, 120)
257257
base = _merge_base(root_dir, compare_branch)
258258
if base is None:
259259
return None
260-
diff = _git(["diff", base, "HEAD", "--name-only", "--no-color"], root_dir)
260+
diff = run_git(["diff", base, "HEAD", "--name-only", "--no-color"], root_dir)
261261
if diff.returncode != 0:
262262
return None
263263
return {f for f in diff.stdout.splitlines() if f.strip()}

0 commit comments

Comments
 (0)