54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Verify commit_count field in chronology rows."""
|
|
from __future__ import annotations
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent))
|
|
from scripts.audit.generate_chronology import walk_track_folders # noqa: E402
|
|
|
|
rows = walk_track_folders(Path("conductor"))
|
|
issues: list[str] = []
|
|
|
|
for i, row in enumerate(rows):
|
|
folder = row["folder_link"]
|
|
track_id = row["track_id"]
|
|
init_sha = row["init_sha"]
|
|
end_sha = row["end_sha"]
|
|
expected_count = row["commit_count"]
|
|
|
|
try:
|
|
result = subprocess.run(
|
|
["git", "log", "--oneline", "--", folder],
|
|
capture_output=True, text=True, timeout=30, check=False,
|
|
)
|
|
actual_count = len(result.stdout.strip().splitlines())
|
|
except Exception:
|
|
continue
|
|
|
|
if init_sha and end_sha:
|
|
if init_sha == end_sha:
|
|
if expected_count not in (0, 1):
|
|
issues.append(
|
|
f"Row {i+2} [{track_id}]: init==end but count={expected_count} (expected 0 or 1)"
|
|
)
|
|
else:
|
|
if expected_count < 1:
|
|
issues.append(
|
|
f"Row {i+2} [{track_id}]: init!=end but count={expected_count} (expected >=1)"
|
|
)
|
|
if abs(expected_count - actual_count) > 1:
|
|
issues.append(
|
|
f"Row {i+2} [{track_id}]: count={expected_count} actual_total={actual_count} (off by >1)"
|
|
)
|
|
else:
|
|
if expected_count != 0:
|
|
issues.append(
|
|
f"Row {i+2} [{track_id}]: no SHAs but count={expected_count}"
|
|
)
|
|
|
|
print(f"Total rows: {len(rows)}")
|
|
print(f"Issues: {len(issues)}")
|
|
for issue in issues[:30]:
|
|
print(f" {issue}")
|