feat(forgejo): add pull request state query to ForgejoClient #406

Merged
mph merged 1 commit from feat/forgejo-pr-state-query into main 2026-07-12 15:42:49 +00:00
Owner

What

Adds ForgejoClient.fetchPullRequestState (plus a pure parsePullRequestState) so callers can query whether a Forgejo PR is merged, open, or closed over the REST API.

Why

ForgejoClient could read a PR's head SHA (fetchPrHeadSha) but had no way to ask for its resolution state. The kanon batch-implement pre-flight catch-up needs exactly that to tell, on restart, whether a merged-but-unadvanced phase's PR actually merged — without it, Forgejo projects always logged "Could not determine forge state" and fell back to re-dispatching claude.

How

Forgejo splits PR resolution across two fields: state (open/closed) and a separate merged boolean (a merged PR is state: closed, merged: true). parsePullRequestState collapses these into a canonical merged/open/closed token; fetchPullRequestState wraps the GET /pulls/{index} call, mirroring the existing fetchPrHeadSha.

Tests

12 new tests in ForgejoClientTest (parser table incl. missing/null merged, unexpected state, malformed JSON; fetch happy-path + 401/404/network). TDD red→green. core compiles -Werror clean; scalafmt gate passed.

Follow-up

The kanon batch-implement command (dev-docs repo) consumes this method and gates on iw-cli >= 0.6.3, so this should ship as 0.6.3 before that plugin branch merges.

## What Adds `ForgejoClient.fetchPullRequestState` (plus a pure `parsePullRequestState`) so callers can query whether a Forgejo PR is merged, open, or closed over the REST API. ## Why `ForgejoClient` could read a PR's head SHA (`fetchPrHeadSha`) but had no way to ask for its resolution state. The kanon `batch-implement` pre-flight catch-up needs exactly that to tell, on restart, whether a merged-but-unadvanced phase's PR actually merged — without it, Forgejo projects always logged "Could not determine forge state" and fell back to re-dispatching claude. ## How Forgejo splits PR resolution across two fields: `state` (open/closed) and a separate `merged` boolean (a merged PR is `state: closed, merged: true`). `parsePullRequestState` collapses these into a canonical `merged`/`open`/`closed` token; `fetchPullRequestState` wraps the `GET /pulls/{index}` call, mirroring the existing `fetchPrHeadSha`. ## Tests 12 new tests in `ForgejoClientTest` (parser table incl. missing/null `merged`, unexpected state, malformed JSON; fetch happy-path + 401/404/network). TDD red→green. `core` compiles `-Werror` clean; scalafmt gate passed. ## Follow-up The kanon `batch-implement` command (dev-docs repo) consumes this method and gates on `iw-cli >= 0.6.3`, so this should ship as **0.6.3** before that plugin branch merges.
feat(forgejo): add pull request state query to ForgejoClient
All checks were successful
CI / compile (pull_request) Successful in 1m16s
CI / format (pull_request) Successful in 6s
CI / lint (pull_request) Successful in 5s
CI / contract (pull_request) Has been skipped
CI / dashboard-build (pull_request) Successful in 54s
CI / test (pull_request) Successful in 10m15s
ab075de98f
Forgejo exposes PR resolution over its REST API, but ForgejoClient only
knew how to read the head SHA of a PR, not whether it was merged, open, or
closed. Add fetchPullRequestState (plus a pure parsePullRequestState) that
collapses Forgejo's separate state/merged fields into a canonical
merged/open/closed token, so callers can query PR resolution without a CLI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mph merged commit e4732b6340 into main 2026-07-12 15:42:49 +00:00
mph deleted branch feat/forgejo-pr-state-query 2026-07-12 15:42:50 +00:00
Sign in to join this conversation.
No description provided.