fix(scripts): attribute bumped versions to their own matrix entry

bump_image_versions.py now locates each matrix.include entry and rewrites the
version: line of the entry whose name: it is, whatever the key order; an entry
it cannot parse unambiguously is a one-line error, and the rewrite is verified
against the YAML before it is written. Files are read and written as UTF-8 with
newline="" so CRLF survives. A shallow clone without a merge-base names the fix
(git fetch --unshallow). check_image_versions.py decodes git's stderr, so errors
no longer print a bytes repr. Untracked files that git ignores were already
skipped; a test now pins that.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-26 06:39:11 +00:00
1 parent c03e492f81
commit a57714342b
4 files changed
+194 -24

No files matched your search

+10 -3
View File
@@ -297,13 +297,20 @@ def git(*args, raw=False):
out = subprocess.run(["git", *args], capture_output=True, check=True).stdout
return out if raw else out.decode("utf-8", errors="replace")
except subprocess.CalledProcessError as exc:
detail = (exc.stderr or "").strip().splitlines()
raise CheckError(f"git {args[0]} failed: {detail[-1] if detail else 'exit ' + str(exc.returncode)}") from exc
stderr = exc.stderr.decode("utf-8", errors="replace") if isinstance(exc.stderr, bytes) else (exc.stderr or "")
detail = stderr.strip().splitlines()
raise CheckError(f"git {args[0]} failed: {detail[-1].strip() if detail else 'exit ' + str(exc.returncode)}") from exc
def changed_paths(base_ref, target="HEAD"):
"""(merge-base, changed paths) between base_ref and target; target None means the working tree."""
base = git("merge-base", "--end-of-options", base_ref, "HEAD").strip()
try:
base = git("merge-base", "--end-of-options", base_ref, "HEAD").strip()
except CheckError as exc:
if git("rev-parse", "--is-shallow-repository").strip() == "true":
raise CheckError(f"no merge-base with {base_ref!r} in a shallow clone: run `git fetch --unshallow` "
"or pass a ref that exists") from exc
raise
# --no-renames: a moved input file shows as a deletion at the old path and an addition
# at the new one, so the old path still counts as touched.
# -z: NUL-separated, unquoted paths, so a non-ASCII name (images/x/café) is compared as is