import json,subprocess
def gh(p):
    r=subprocess.run(["gh","api",p],capture_output=True,text=True)
    if r.returncode!=0: return None
    return json.loads(r.stdout)
repos=json.load(open('repos.json'))
forks=[r['name'] for r in repos if r['isFork']]
res=[]
for n in forks:
    d=gh(f"repos/oscartbeaumont/{n}")
    if not d: res.append((n,"?","?","?","?")); continue
    p=d['parent']['full_name'] if d.get('parent') else None
    pb=d['parent']['default_branch'] if d.get('parent') else None
    ahead="?"
    if p:
        c=gh(f"repos/oscartbeaumont/{n}/compare/{pb}...{d['default_branch']}")
        if c: ahead=f"{c['ahead_by']}/{c['behind_by']}"
    res.append((n,p,ahead,d['pushed_at'][:10],'PRIVATE' if d['private'] else ''))
for r in res: print(" | ".join(map(str,r)))
