Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
18 lines
1.1 KiB
Python
18 lines
1.1 KiB
Python
import hashlib,json,subprocess,sys
|
|
from pathlib import Path
|
|
root=Path('/home/jakub/devel/escapistsrereintroduced')
|
|
proposal=Path(sys.argv[1]); manifest=json.loads((proposal/'source-manifest.json').read_text()); patch=proposal/'fix.patch'
|
|
if 'files' not in manifest:manifest['files']={manifest['file']:manifest}
|
|
def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() if p.is_file() else None
|
|
assert sha(patch)==manifest['patch_sha256']
|
|
for name,entry in manifest['files'].items():
|
|
p=root/name
|
|
assert p.resolve().is_relative_to(root)
|
|
assert sha(p)==entry['baseline_sha256'],name
|
|
cached=subprocess.check_output(['git','diff','--cached','--binary'],cwd=root)
|
|
subprocess.run(['git','apply','--check',str(patch)],cwd=root,check=True)
|
|
subprocess.run(['git','apply',str(patch)],cwd=root,check=True)
|
|
for name,entry in manifest['files'].items():assert sha(root/name)==entry.get('proposal_sha256',entry.get('proposed_sha256')),name
|
|
assert subprocess.check_output(['git','diff','--cached','--binary'],cwd=root)==cached
|
|
print('Applied exact proposal:',proposal,len(manifest['files']),'paths; staged diff unchanged')
|