24 lines
4.3 KiB
Plaintext
24 lines
4.3 KiB
Plaintext
from pathlib import Path
|
|
import json,hashlib,os,datetime,subprocess,concurrent.futures
|
|
R=Path.cwd();REF=R/'docs/hel-892/h3-mv-reference';D=R/'docs/hel-892/h3-mv-document-evidence';REF.mkdir(exist_ok=True);D.mkdir(exist_ok=True);now=datetime.datetime.now(datetime.timezone.utc).isoformat();rows=[]
|
|
def fetch(spec):
|
|
key,repo,rev,files=spec;cache=R/('.local-evidence/mv-'+key+'-git');subprocess.run(['git','init','--bare',str(cache)],check=True,capture_output=True)
|
|
def git(*args):return subprocess.check_output(['git','-C',str(cache),*args],timeout=80)
|
|
p=subprocess.run(['git','-C',str(cache),'fetch','--filter=blob:none','--depth=1','https://github.com/'+repo+'.git',rev],capture_output=True,timeout=100);(REF/(key+'-fetch.txt')).write_bytes(p.stdout+p.stderr);assert p.returncode==0,p.stderr
|
|
commit=git('rev-parse','FETCH_HEAD^{commit}').decode().strip();obj=git('rev-parse','FETCH_HEAD').decode().strip();tree=git('rev-parse',commit+'^{tree}').decode().strip();cb=git('cat-file','commit',commit);tb=git('cat-file','tag' if obj!=commit else 'commit',obj);(REF/(key+'-commit.txt')).write_bytes(cb);(REF/(key+'-tag.txt')).write_bytes(tb);(REF/(key+'-tag.json')).write_text(json.dumps(dict(object=obj,commit=commit,tag=rev),indent=2)+'\n')
|
|
entries=[]
|
|
for line in git('ls-tree','-r',commit).decode().splitlines():
|
|
meta,path=line.split('\t');mode,typ,sha=meta.split();entries.append(dict(path=path,mode=mode,type=typ,sha=sha))
|
|
(REF/(key+'-tree.json')).write_text(json.dumps(dict(sha=tree,truncated=False,tree=entries),indent=2)+'\n');result=[]
|
|
for f in files:
|
|
ent=next((x for x in entries if x['path']==f),None)
|
|
if not ent:print('MISSING',key,f,flush=True);continue
|
|
raw=git('show',commit+':'+f);assert len(raw)<3000000;name=key+'__'+f.replace('/','__');(REF/name).write_bytes(raw)
|
|
result.append(dict(id=key,repo=repo,file=f,local_file=name,commit=commit,tree=tree,tag=rev,url=f'https://raw.githubusercontent.com/{repo}/{commit}/{f}',sha256=hashlib.sha256(raw).hexdigest(),git_blob_sha1=ent['sha'],acquisition_time=now,reverified_at=now,license_file=key+'__LICENSE',identity_root='.',identity_key=key,transport='filtered Git necessary text only',applicability='本图独立准确版本静态核准,不执行或认证安装/恢复'))
|
|
print('FETCH',key,commit,len(result),flush=True);return result
|
|
|
|
specs=[('selflift','slmonker/selflift-Avatar','5df288a083fa8585a563c9c2af7ebfa0e79188c7',['__init__.py','pyproject.toml','requirements.txt','LICENSE']),('longvideo','Zzz1phyrf/ComfyUI-H3-LongVideo','2c1361d6ab4a270b72eb8fd9de826ac61d54e5bb',['__init__.py','pyproject.toml','requirements.txt','LICENSE']),('kjattention','kijai/ComfyUI-KJNodes','3f20054214fec9f9234fd3841ae6f1e4287948f6',['__init__.py','nodes/model_optimization_nodes.py','LICENSE','pyproject.toml','requirements.txt']),('kj','kijai/ComfyUI-KJNodes','c9869eade9920a1b949de07c4a197156006bcceb',['__init__.py','nodes/model_optimization_nodes.py','LICENSE','pyproject.toml','requirements.txt']),('core0342','Comfy-Org/ComfyUI','v0.34.2',['nodes.py','comfy_extras/nodes_audio.py','comfy_extras/nodes_lt.py','comfy_extras/nodes_mask.py','comfy_extras/nodes_minimax_h3.py','comfy_extras/nodes_preview_any.py','comfy_api/latest/_io.py','comfy_api/latest/_io_public.py','LICENSE','requirements.txt']),('core0301','Comfy-Org/ComfyUI','v0.30.1',['nodes.py','comfy_extras/nodes_resolution.py','LICENSE','requirements.txt']),('core0331','Comfy-Org/ComfyUI','v0.33.1',['nodes.py','LICENSE','requirements.txt']),('core0330','Comfy-Org/ComfyUI','v0.33.0',['comfy_extras/nodes_custom_sampler.py','comfy/samplers.py','nodes.py','LICENSE','requirements.txt']),('core0352','Comfy-Org/ComfyUI','v0.35.2',['nodes.py','LICENSE','requirements.txt']),('core0360','Comfy-Org/ComfyUI','v0.36.0',['comfy_extras/nodes_custom_sampler.py','comfy/samplers.py','nodes.py','LICENSE','requirements.txt']),('frontend','Comfy-Org/ComfyUI_frontend','v1.47.11',['package.json','pnpm-lock.yaml','src/scripts/widgets.ts','src/scripts/valueControl.ts','src/core/graph/widgets/dynamicWidgets.ts','src/lib/litegraph/LICENSE','src/lib/litegraph/src/litegraph.ts','src/lib/litegraph/src/LGraphNode.ts','LICENSE'])]
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=4)as pool:
|
|
for rr in pool.map(fetch,specs):rows.extend(rr)
|
|
(REF/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n')
|