From b8e5b1c4c4fda26f1940b2b5e41ef9e18b272092 Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Sat, 12 Sep 2026 01:40:54 -0500 Subject: [PATCH 1/8] fix flake update --- .github/workflows/flake-update.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/flake-update.yml b/.github/workflows/flake-update.yml index 27ec96d..83ed8d8 100644 --- a/.github/workflows/flake-update.yml +++ b/.github/workflows/flake-update.yml @@ -5,10 +5,6 @@ on: - cron: "17 4 * * *" workflow_dispatch: -permissions: - contents: write - pull-requests: write - jobs: update: runs-on: nix -- 2.55.0 From d81d948bae62ddf3568b70084460d9ec3e8a2c29 Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:48:20 -0500 Subject: [PATCH 2/8] fix unrelated workflow --- .github/workflows/diff-pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/diff-pr.yml b/.github/workflows/diff-pr.yml index 17b0abf..e363fc1 100644 --- a/.github/workflows/diff-pr.yml +++ b/.github/workflows/diff-pr.yml @@ -20,7 +20,9 @@ jobs: fetch-depth: 0 - name: worktree base for diff - run: git worktree add "$RUNNER_TEMP/base" "${{ github.event.pull_request.base.sha }}" + run: | + git fetch origin ${{ github.event.pull_request.base.ref }} + git worktree add "$RUNNER_TEMP/base" "origin/${{ github.event.pull_request.base.ref }}" - name: build closures and render diff run: | -- 2.55.0 From 6ba18264ac0609a60f424485c270f82fc7c1a869 Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Sun, 13 Sep 2026 11:55:32 -0500 Subject: [PATCH 3/8] fix again --- .github/workflows/flake-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flake-update.yml b/.github/workflows/flake-update.yml index 83ed8d8..cded23c 100644 --- a/.github/workflows/flake-update.yml +++ b/.github/workflows/flake-update.yml @@ -15,7 +15,7 @@ jobs: - name: open/update PR env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.BOT_TOKEN }} API: ${{ github.api_url }} REPO: ${{ github.repository }} run: | -- 2.55.0 From bc6d66432a70f942663c49cb2315c34f09f0effe Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:32:55 -0500 Subject: [PATCH 4/8] fix again --- .github/workflows/diff-pr.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/diff-pr.yml b/.github/workflows/diff-pr.yml index e363fc1..d8fbabb 100644 --- a/.github/workflows/diff-pr.yml +++ b/.github/workflows/diff-pr.yml @@ -17,12 +17,18 @@ jobs: steps: - uses: actions/checkout@v4 with: + ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - - name: worktree base for diff + - name: merge base branch run: | + git config user.email "ci@localhost" + git config user.name "CI" git fetch origin ${{ github.event.pull_request.base.ref }} - git worktree add "$RUNNER_TEMP/base" "origin/${{ github.event.pull_request.base.ref }}" + git merge --no-edit origin/${{ github.event.pull_request.base.ref }} + + - name: worktree base for diff + run: git worktree add "$RUNNER_TEMP/base" "origin/${{ github.event.pull_request.base.ref }}" - name: build closures and render diff run: | -- 2.55.0 From 581f531bf4e2f22354c9d6dcffa4c03a83ebe5b4 Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Sun, 13 Sep 2026 12:57:16 -0500 Subject: [PATCH 5/8] meow --- ci.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ci.py b/ci.py index 61076ea..9b38e61 100644 --- a/ci.py +++ b/ci.py @@ -8,6 +8,7 @@ import re import subprocess import subprocess_tee import sys +import urllib.error import urllib.request from collections import Counter from pathlib import Path @@ -26,6 +27,10 @@ def git(*args, check=True): return run("git", *args, check=check, capture_output=True) +class GiteaError(Exception): + pass + + def gitea(method, path, body=None): url = f'{os.environ["API"]}/repos/{os.environ["REPO"]}{path}' data = json.dumps(body).encode() if body is not None else None @@ -37,7 +42,11 @@ def gitea(method, path, body=None): with urllib.request.urlopen(req) as resp: raw = resp.read() except urllib.error.HTTPError as e: - sys.exit(f"gitea {method} {path}: {e.code} {e.reason}\n{e.read().decode()}") + try: + detail = json.loads(e.read()).get("message", e.reason) + except (json.JSONDecodeError, UnicodeDecodeError): + detail = e.reason + raise GiteaError(f"{method} {path}: {e.code} {detail}") from None return json.loads(raw) if raw else None -- 2.55.0 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 6/8] 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(): -- 2.55.0 From 86d78a47601d3320708ab00c0eaaec84b2b056c9 Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Sun, 13 Sep 2026 13:48:50 -0500 Subject: [PATCH 7/8] temp --- .github/workflows/flake-update.yml | 2 ++ ci.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/flake-update.yml b/.github/workflows/flake-update.yml index cded23c..2baadce 100644 --- a/.github/workflows/flake-update.yml +++ b/.github/workflows/flake-update.yml @@ -10,6 +10,8 @@ jobs: runs-on: nix steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - run: nix flake update -L diff --git a/ci.py b/ci.py index 53b1b40..6b0fd59 100644 --- a/ci.py +++ b/ci.py @@ -481,10 +481,10 @@ def open_pr(args): if push.returncode != 0: raise RuntimeError(f"git push failed:\n{push.stderr}") - owner = os.environ["REPO"].split("/")[0] - existing = gitea("GET", f"/pulls?state=open&head={owner}:{args.branch}") + pulls = gitea("GET", "/pulls?state=open") + existing = next((pr for pr in pulls if pr["head"]["ref"] == args.branch), None) if existing: - print(f"PR #{existing[0]['number']} already open, pushed update") + print(f"PR #{existing['number']} already open, pushed update") return labels = [label_id(args.label)] if args.label else [] pr = gitea("POST", "/pulls", -- 2.55.0 From d18e1b6c157fcce4748b00a32bbe40743dd46985 Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Wed, 16 Sep 2026 19:41:55 -0500 Subject: [PATCH 8/8] try fix again --- ci.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.py b/ci.py index 6b0fd59..a3d8db0 100644 --- a/ci.py +++ b/ci.py @@ -481,7 +481,7 @@ def open_pr(args): if push.returncode != 0: raise RuntimeError(f"git push failed:\n{push.stderr}") - pulls = gitea("GET", "/pulls?state=open") + pulls = gitea("GET", f"/pulls?state=open&base_branch={args.base}") existing = next((pr for pr in pulls if pr["head"]["ref"] == args.branch), None) if existing: print(f"PR #{existing['number']} already open, pushed update") -- 2.55.0