"""Synthetic GitLab fixture: run against a disposable authenticated project."""
import json, subprocess, sys
project, branch = sys.argv[1:3]
def api(path, payload):
 return json.loads(subprocess.check_output(['glab','api','-X','POST',f'projects/{project}/{path}','--input','-'],input=json.dumps(payload).encode()))
api('repository/branches', {'branch':branch,'ref':'main'})
api('repository/commits', {'branch':branch,'commit_message':'Synthetic diff fixture','actions':[{'action':'create','file_path':f'file{i:02}.ts','content':'export const marker = "OLD-DISTINCTIVE-LINE";\n' if i==1 else f'export const value{i} = {i};\n'} for i in range(1,36)]})
mr=api('merge_requests', {'source_branch':branch,'target_branch':'main','title':'Diff reload proof'})
print(mr['iid'])
# Once page two has failed in the app, replace file01.ts via this commit payload:
print(json.dumps({'branch':branch,'commit_message':'Replace obsolete line','actions':[{'action':'update','file_path':'file01.ts','content':'export const marker = "NEW-REPLACEMENT-LINE";\n'}]}))
