"""Synthetic GitLab fixture for the native BOM PR-description comparison.
Requires an authenticated glab CLI. Creates a disposable private project.
Clone its http_url_to_repo, then add the clone with `t3 project add` on each
fresh isolated backend. On Pixel 9 Android 36 in light theme, pair the dev
client, open Pulls, search BOM single/double, open Overview, capture Description,
and tap the reference. Base links #1 + plain 1 and opens issue 1; head should
link all of #11 and open issue 11. No issue is created, so its detail can fail.
"""
import json, subprocess

def api(path, data):
    return json.loads(subprocess.check_output(
        ['glab', 'api', '-X', 'POST', path, '--input', '-'],
        input=json.dumps(data), text=True))

project = api('projects', {'name':'bom-proof-reproduction',
    'visibility':'private', 'initialize_with_readme':True})
pid = project['id']
for count, label in [(1,'single'), (2,'double')]:
    branch = 'bom-' + label
    api(f'projects/{pid}/repository/branches', {'branch':branch, 'ref':'main'})
    api(f'projects/{pid}/repository/commits', {'branch':branch,
        'commit_message':'Synthetic BOM fixture', 'actions':[{
            'action':'create', 'file_path':branch+'.txt', 'content':'fixture'}]})
    api(f'projects/{pid}/merge_requests', {'source_branch':branch,
        'target_branch':'main', 'title':'BOM '+label,
        'description':'\ufeff'*count+'See [the docs](https://example.com/docs) :tada: Fixes #11\n\n- [ ] Write tests'})
print(project['http_url_to_repo'])
print('Delete the disposable project after verification.')
