61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
"""Freeze every baseline blob beyond an explicit narrow correction allowlist."""
|
|
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
HERE = Path(__file__).resolve().parent
|
|
BASE = "0d38671f170db309e52a94104cf87889aa53dff2"
|
|
|
|
|
|
def main():
|
|
allowed = {
|
|
"calliope-backend/src/calliope/comfyui/fixed_document.py",
|
|
"calliope-backend/src/calliope/comfyui/source_reviews.json",
|
|
}
|
|
frozen, changed, originals = [], [], []
|
|
for entry in (
|
|
subprocess.check_output(["git", "ls-tree", "-rz", BASE]).rstrip(b"\0").split(b"\0")
|
|
):
|
|
meta, encoded = entry.split(b"\t", 1)
|
|
name = encoded.decode()
|
|
mode, kind, digest = meta.decode().split()
|
|
assert kind == "blob"
|
|
raw = (ROOT / name).read_bytes()
|
|
actual = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
|
|
if name in allowed:
|
|
if actual != digest:
|
|
changed.append(name)
|
|
continue
|
|
assert actual == digest, name
|
|
row = dict(path=name, sha256=hashlib.sha256(raw).hexdigest(), git_blob_sha1=digest)
|
|
frozen.append(row)
|
|
if name.startswith("example_ComfyUI_workflows/") or (
|
|
name.startswith("docs/hel-892/supplied-api/") and name.endswith(".api.json")
|
|
):
|
|
originals.append(row)
|
|
assert len(originals) == 163
|
|
(HERE / "frozen-baseline.json").write_text(
|
|
json.dumps(
|
|
dict(
|
|
base=BASE,
|
|
count=len(frozen),
|
|
allowed_changes=sorted(allowed),
|
|
changed=changed,
|
|
original_count=163,
|
|
originals=originals,
|
|
files=frozen,
|
|
),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
print("PASS baseline", len(frozen), "blobs incl163 originals frozen; explicit narrow allowlist")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|