Files
EscapistsReintroduced/docs/evidence/mounted-interception-2026-10-02/integrate.py
T
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

38 lines
2.3 KiB
Python

from pathlib import Path
import hashlib,json,sys,subprocess,shutil
R=Path('/home/jakub/devel/escapistsrereintroduced');B=Path('/tmp/erri-mounted-intercept-root-1247')
sys.path.insert(0,str(R/'tools'))
from source_manifest import addon_manifest
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
before=json.loads((B/'baseline.json').read_text())
assert addon_manifest(R)==before['authored']
assert hashlib.sha256(subprocess.check_output(['git','diff','--cached','--binary'],cwd=R)).hexdigest()==before['index_sha256']
files={}
for label in ['convoy','rules']:
p=Path('/tmp/erri-mounted-intercept-'+label+'-1247')
for folder in ['addons','tests']:
for f in (p/folder).rglob('*'):
if f.is_file() and f.suffix in {'.c','.py'} and '__pycache__' not in f.parts:
files[str(f.relative_to(p))]=f
files['addons/core/Scripts/Game/ERR/10_AI/ERR_HQ.c']=B/'ERR_HQ.c'
files['addons/core/Scripts/Game/ERR/10_AI/ERR_HQMountedDispatch.c']=B/'ERR_HQMountedDispatch.c'
files['tests/test_hq_convoy_combat.py']=B/'test_hq_convoy_combat.py'
files['tests/test_hq_mounted_dispatch.py']=Path('/tmp/erri-motorized-intercept-review/test_hq_mounted_dispatch.py')
mapping={n:{'before':sha(R/n) if (R/n).is_file() else None,'after':sha(p),'proposal':str(p)} for n,p in files.items()}
(B/'integration-inputs.json').write_text(json.dumps(mapping,indent=2)+'\n')
for n,p in files.items():
dst=R/n; backup=B/'before'/n
if dst.exists():
backup.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(dst,backup)
dst.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(p,dst)
tool=R/'tools/check.py';backup=B/'before/tools/check.py';backup.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(tool,backup)
newtests=[Path(n).name for n,v in mapping.items() if n.startswith('tests/') and v['before'] is None]
s=tool.read_text();anchor=" for name in ['test_native_maintenance_refuel.py'"
assert s.count(anchor)==1
s=s.replace(anchor,' for name in ['+''.join(repr(n)+', ' for n in sorted(newtests))+"'test_native_maintenance_refuel.py'")
tool.write_text(s)
mapping['tools/check.py']={'before':sha(backup),'after':sha(tool),'new_tests':newtests}
(B/'integration-inputs.json').write_text(json.dumps(mapping,indent=2)+'\n')
(B/'source-after.json').write_text(json.dumps(addon_manifest(R),indent=2)+'\n')
print(json.dumps({'files':list(mapping),'new_tests':newtests,'authored':len(addon_manifest(R))},indent=2))