From e692589fe9ff0b9cf135df5d7d41b674cad10986 Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Sun, 13 Sep 2026 13:16:31 -0500 Subject: [PATCH] meow --- ci.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ci.py b/ci.py index 9b38e61..53b1b40 100644 --- a/ci.py +++ b/ci.py @@ -475,16 +475,24 @@ def open_pr(args): host = os.environ["API"].removesuffix("/api/v1") auth = base64.b64encode(f'token:{os.environ["GH_TOKEN"]}'.encode()).decode() - git("-c", f"http.extraHeader=Authorization: Basic {auth}", - "push", "-f", f'{host}/{os.environ["REPO"]}.git', f"HEAD:{args.branch}") + push = git("-c", f"http.extraHeader=Authorization: Basic {auth}", + "push", "-f", f'{host}/{os.environ["REPO"]}.git', f"HEAD:{args.branch}", + check=False) + if push.returncode != 0: + raise RuntimeError(f"git push failed:\n{push.stderr}") owner = os.environ["REPO"].split("/")[0] - if gitea("GET", f"/pulls?state=open&head={owner}:{args.branch}"): + existing = gitea("GET", f"/pulls?state=open&head={owner}:{args.branch}") + if existing: + print(f"PR #{existing[0]['number']} already open, pushed update") return labels = [label_id(args.label)] if args.label else [] - gitea("POST", "/pulls", - {"title": args.title, "head": args.branch, "base": args.base, - "body": Path(args.body_file).read_text(), "labels": labels}) + pr = gitea("POST", "/pulls", + {"title": args.title, "head": args.branch, "base": args.base, + "body": Path(args.body_file).read_text(), "labels": labels}) + if not pr or "number" not in pr: + raise GiteaError(f"POST /pulls: unexpected response: {json.dumps(pr)}") + print(f"opened PR #{pr['number']}") def main():