import json, pathlib, subprocess, sys, time
root=pathlib.Path(sys.argv[1]).resolve()
root.mkdir(parents=True, exist_ok=True)
created=subprocess.run(['glab','api','-X','POST','projects','-f',f'name=t3-large-mr-proof-{int(time.time())}','-f','visibility=private'],capture_output=True,text=True,check=True)
(root/'project.json').write_text(created.stdout)
p=json.loads((root/'project.json').read_text()); repo=root/'fixture'; repo.mkdir(exist_ok=True)
def run(*args): subprocess.run(args,cwd=repo,check=True,stdout=subprocess.DEVNULL)
run('git','init','-b','main'); run('git','config','user.name','Scenario'); run('git','config','user.email','scenario@example.invalid')
(repo/'src').mkdir(exist_ok=True)
for n in range(120): (repo/f'src/file-{n:03}.txt').write_text(''.join(f'original {i:03}\n' for i in range(40)))
run('git','add','.'); run('git','commit','-m','Initial sample'); run('git','remote','add','origin',p['http_url_to_repo']); run('git','push','-u','origin','main'); run('git','checkout','-b','large-change')
for n in range(120): (repo/f'src/file-{n:03}.txt').write_text(''.join(f'revised {i:03}\n' for i in range(40)))
for name,count in [('medium',2000),('huge',20000)]: (repo/f'src/{name}.txt').write_text(''.join(f'{name} reviewable added line {i:05}\n' for i in range(1,count+1)))
run('git','add','.'); run('git','commit','-m','Change 122 files'); run('git','push','-u','origin','large-change')
res=subprocess.run(['glab','api','-X','POST',f'projects/{p["id"]}/merge_requests','-f','source_branch=large-change','-f','target_branch=main','-f','title=Review all 122 changed files'],capture_output=True,text=True,check=True)
(root/'mr.json').write_text(res.stdout)
print(p['id'],p['path_with_namespace'])
