import pathlib, subprocess, sys
root = pathlib.Path(sys.argv[1]).resolve()
checkout = pathlib.Path(sys.argv[2]).resolve()
def run(*args, cwd=None):
    subprocess.run(args, cwd=cwd, check=True, stdout=subprocess.DEVNULL)
root.mkdir(parents=True, exist_ok=True)
source = root / 'source'
source.mkdir(exist_ok=True)
run('git','init',str(source))
run('git','-C',str(source),'-c','user.name=Example','-c','user.email=example@example.com','commit','--allow-empty','-m','Synthetic fixture')
for kind, remote in [('https','https://dev.azure.com/example-org/My%20Project/_git/my-repo'),('ssh','git@ssh.dev.azure.com:v3/example-org/MiXeDProject/MyRepo')]:
    for parent in ['one','two']:
        repo = root / kind / parent / ('my-repo' if kind == 'https' else 'MyRepo')
        repo.parent.mkdir(parents=True, exist_ok=True)
        run('git','clone',str(source),str(repo))
        run('git','-C',str(repo),'remote','set-url','origin',remote)
        run('node','apps/server/src/bin.ts','project','add','--base-dir',str(checkout / '.t3'),str(repo),cwd=checkout)
print('Added four synthetic projects via the real project CLI.')
