Datasets:
File size: 1,098 Bytes
b1a18a7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | """Record committed git task/build/registry bytes; never untracked bytecode."""
import hashlib
import json
from pathlib import Path
import subprocess
ROOT=Path(__file__).resolve().parent
def update():
path=ROOT/'task-source.json';source=json.loads(path.read_text());repo=ROOT/'.state/task-registry-repo'
revision=source['commit']
files=subprocess.check_output(['git','-C',str(repo),'ls-tree','-r','--name-only',revision,'tasks','build','registry.json'],text=True).splitlines()
manifest={};build={}
for file in files:
data=subprocess.check_output(['git','-C',str(repo),'show',f'{revision}:{file}'])
sha=hashlib.sha256(data).hexdigest()
if file.startswith('tasks/'):
_,task,relative=file.split('/',2)
manifest.setdefault(task,{})[relative]=sha
elif file.startswith('build/'):
build[file]=sha
else:
source['registry_sha256']=sha
source['task_manifest']=manifest;source['build_manifest']=build
path.write_text(json.dumps(source,indent=2)+'\n')
if __name__=='__main__':
update()
|