From e03b2f2326a507ece1122b0ab2d1b39f8790123e Mon Sep 17 00:00:00 2001 From: AlbertoPMDM Date: Wed, 18 Nov 2026 20:43:17 -0600 Subject: [PATCH] tools: vendor check compares contents where there is no git history (image) --- tools/vendor_legacy.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/vendor_legacy.py b/tools/vendor_legacy.py index d8a8536..42c5da3 100644 --- a/tools/vendor_legacy.py +++ b/tools/vendor_legacy.py @@ -96,9 +96,13 @@ def header(src_name: str, rel: str, sha: str, commit: str) -> str: f"# source sha256 {sha}. Do not edit: changed only in imports.\n") -def submodule_commit() -> str: - r = subprocess.run(["git", "-C", str(ROOT / "biomarcadores-tea"), "rev-parse", "--short", "HEAD"], - capture_output=True, text=True, check=True) +def submodule_commit() -> str | None: + """The submodule's commit, or None where there is no git history (e.g. a Docker image).""" + try: + r = subprocess.run(["git", "-C", str(ROOT / "biomarcadores-tea"), "rev-parse", "--short", "HEAD"], + capture_output=True, text=True, check=True) + except (OSError, subprocess.CalledProcessError): + return None return r.stdout.strip() @@ -121,7 +125,12 @@ def main(argv=None) -> int: ap.add_argument("--check", action="store_true") args = ap.parse_args(argv) commit = submodule_commit() - if commit != PINNED["biomarcadores-tea"]: + if commit is None: + if not args.check: + print("no git history: cannot confirm the pinned commit; refusing to re-vendor", file=sys.stderr) + return 2 + print("no git history: comparing contents without confirming the commit", file=sys.stderr) + elif commit != PINNED["biomarcadores-tea"]: print(f"biomarcadores-tea is at {commit}, legacy is pinned to " f"{PINNED['biomarcadores-tea']}: check out the pinned commit first", file=sys.stderr) return 2