tools: vendor check compares contents where there is no git history (image)

This commit is contained in:
AlbertoPMDM
2026-11-18 20:43:17 -06:00
parent 849b05f922
commit e03b2f2326
+13 -4
View File
@@ -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") f"# source sha256 {sha}. Do not edit: changed only in imports.\n")
def submodule_commit() -> str: def submodule_commit() -> str | None:
r = subprocess.run(["git", "-C", str(ROOT / "biomarcadores-tea"), "rev-parse", "--short", "HEAD"], """The submodule's commit, or None where there is no git history (e.g. a Docker image)."""
capture_output=True, text=True, check=True) 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() return r.stdout.strip()
@@ -121,7 +125,12 @@ def main(argv=None) -> int:
ap.add_argument("--check", action="store_true") ap.add_argument("--check", action="store_true")
args = ap.parse_args(argv) args = ap.parse_args(argv)
commit = submodule_commit() 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 " print(f"biomarcadores-tea is at {commit}, legacy is pinned to "
f"{PINNED['biomarcadores-tea']}: check out the pinned commit first", file=sys.stderr) f"{PINNED['biomarcadores-tea']}: check out the pinned commit first", file=sys.stderr)
return 2 return 2