Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
12 lines
1.2 KiB
Python
12 lines
1.2 KiB
Python
from pathlib import Path
|
|
import hashlib,json,subprocess,difflib
|
|
P=Path('/tmp/erri-mounted-intercept-convoy-1247');R=Path('/home/jakub/devel/escapistsrereintroduced');meta=json.loads((P/'baseline.json').read_text());manifest={};patch=[]
|
|
for f in sorted([*P.glob('addons/**/*.c'),*P.glob('tests/test_*.py')]):
|
|
rel=str(f.relative_to(P));before=(P/'baseline'/rel).read_bytes();after=f.read_bytes();assert(R/rel).read_bytes()==before,rel
|
|
if rel not in meta:meta[rel]={'working_sha256':hashlib.sha256(before).hexdigest(),'index_sha256':hashlib.sha256(subprocess.check_output(['git','show',':'+rel],cwd=R)).hexdigest()}
|
|
if before==after:continue
|
|
manifest[rel]=hashlib.sha256(after).hexdigest();patch.extend(difflib.unified_diff(before.decode().splitlines(True),after.decode().splitlines(True),fromfile='a/'+rel,tofile='b/'+rel))
|
|
(P/'baseline.json').write_text(json.dumps(meta,indent=2)+'\n');(P/'source-manifest.json').write_text(json.dumps(manifest,indent=2)+'\n');(P/'fix.patch').write_text(''.join(patch))
|
|
r=subprocess.run(['git','apply','--check',str(P/'fix.patch')],cwd=R,text=True,capture_output=True);(P/'apply-check.log').write_text(r.stdout+r.stderr);assert r.returncode==0,r.stderr
|
|
print('Patch',len(manifest),'files; applicability check passed')
|