import os, subprocess, json, pathlib root=pathlib.Path(os.environ['REVIEW_PROOF_OUTPUT']) def run(args,cwd=None): return subprocess.check_output(args,cwd=cwd,text=True).strip() org=os.environ['AZURE_DEVOPS_TEST_ORG']; project=os.environ['AZURE_DEVOPS_TEST_PROJECT'] repo=json.loads(run(['az','repos','list','--organization',org,'--project',project,'-o','json']))[0] p=root/'repository'; p.mkdir(exist_ok=True) run(['git','init','-q','--initial-branch=proof-42278-base'],p) run(['git','config','user.name','Scenario'],p); run(['git','config','user.email','scenario@example.invalid'],p) (p/'b.ts').write_text(''.join(f'export const value{i} = {i};\n' for i in range(1,51))) run(['git','add','b.ts'],p); run(['git','commit','-qm','Synthetic review diff'],p) url=repo['remoteUrl']; helper='!f() { echo username=pat; echo "password=$AZURE_DEVOPS_EXT_PAT"; }; f' def push(branch): run(['git','-c','credential.helper='+helper,'push',url,branch],p) push('proof-42278-base') run(['git','checkout','-qb','proof-42278-head'],p) (p/'b.ts').write_text((p/'b.ts').read_text().replace('value10 = 10','value10 = 100')) run(['git','commit','-qam','Change line ten'],p); push('proof-42278-head') pr=json.loads(run(['az','repos','pr','create','--organization',org,'--project',project,'--repository',repo['id'],'--source-branch','proof-42278-head','--target-branch','proof-42278-base','--title','Synthetic review range proof 42278','-o','json'])) (root/'fixture.json').write_text(json.dumps({'url':url,'number':pr['pullRequestId'],'repo':repo['id']})) print('Created synthetic PR',pr['pullRequestId'])