"Acquire necessary pinned text only; no upstream imports or execution." import datetime import hashlib import json import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[3] OUT = Path(__file__).resolve().parent REF = OUT.parent / "flux2-person-reference" def main(): rows = [] specs = [ ( "frontsub", "Comfy-Org/ComfyUI_frontend", "v1.36.14", ["src/lib/litegraph/src/subgraph/SubgraphNode.ts", "LICENSE"], ), ("save", "Comfy-Org/ComfyUI", "v0.9.2", ["nodes.py", "folder_paths.py", "LICENSE"]), ( "background", "Comfy-Org/ComfyUI", "v0.28.3", [ "nodes.py", "comfy_extras/nodes_mask.py", "comfy_extras/nodes_bg_removal.py", "comfy/bg_removal_model.py", "folder_paths.py", "comfy_extras/nodes_compositing.py", "comfy_extras/nodes_post_processing.py", "LICENSE", ], ), ( "scale", "Comfy-Org/ComfyUI", "v0.8.2", [ "comfy_extras/nodes_images.py", "comfy_extras/nodes_post_processing.py", "comfy/utils.py", "LICENSE", ], ), ( "layer", "aining2022/ComfyUI_Swwan", "881bc91790da6b907d3d28e5b91b295b9aef06ee", ["image_scale_by_aspect_ratio_v2.py", "layerstyle_utils.py", "__init__.py", "LICENSE"], ), ] for key, repo, tag, files in specs: cache = ROOT / ".local-evidence" / ("flux2-person-" + key + "-git") cache.mkdir(parents=True, exist_ok=True) subprocess.run(["git", "init", "--bare", str(cache)], check=True, stdout=subprocess.DEVNULL) subprocess.run( [ "git", "-C", str(cache), "fetch", "--filter=blob:none", "--depth=1", "https://github.com/" + repo + ".git", ("refs/tags/" + tag) if tag.startswith("v") else tag, ], check=True, ) def git(*args): return subprocess.check_output(["git", "-C", str(cache), *args]) rev = git("rev-parse", "FETCH_HEAD^{commit}").decode().strip() tree = git("rev-parse", rev + "^{tree}").decode().strip() (REF / (key + "-commit.txt")).write_bytes(git("cat-file", "commit", rev)) (REF / (key + "-tag.txt")).write_bytes(git("cat-file", "-p", "FETCH_HEAD")) (REF / (key + "-tag.json")).write_text( json.dumps( dict( ref=("refs/tags/" + tag) if tag.startswith("v") else tag, commit=rev, object=git("rev-parse", "FETCH_HEAD").decode().strip(), ), indent=2, ) + "\n" ) entries = [] for line in git("ls-tree", "-r", rev).decode().splitlines(): head, path = line.split("\t", 1) mode, kind, sha = head.split() entries.append(dict(path=path, mode=mode, type=kind, sha=sha)) (REF / (key + "-tree.json")).write_text( json.dumps(dict(sha=tree, truncated=False, tree=entries), indent=2) + "\n" ) missing = [] for f in files: ent = next((x for x in entries if x["path"] == f), None) if ent is None: missing.append(f) continue raw = git("show", rev + ":" + f) name = key + "__" + f.replace("/", "__") (REF / name).write_bytes(raw) rows.append( dict( id=key, repo=repo, file=f, local_file=name, commit=rev, tree=tree, tag=tag, url=f"https://raw.githubusercontent.com/{repo}/{rev}/{f}", sha256=hashlib.sha256(raw).hexdigest(), git_blob_sha1=ent["sha"], acquisition_time=datetime.datetime.now(datetime.timezone.utc).isoformat(), license_file=key + "__LICENSE", transport="filtered git; selected text blobs only", applicability="本图独立声明版本;UE/tab/宿主恢复未知", ) ) (REF / (key + "-absent.json")).write_text(json.dumps(missing, indent=2) + "\n") (REF / "new-sources.json").write_text( json.dumps(dict(sources=rows), ensure_ascii=False, indent=2) + "\n" ) if __name__ == "__main__": main()