fix(prs): add --json output and fix relative-URL crash (FJ-2) #21

Merged
David merged 2 commits from fix/pr-status-json-relative-url into main 2026-05-28 19:44:25 +02:00
Owner

fj pr status <id> crashed when the Forgejo API returned commit statuses whose target_url was relative (e.g. /owner/repo/actions/runs/85/jobs/0). The crash came from forgejo_api::structs::CommitStatus::target_url being typed Option<url::Url>, and the url crate rejecting relative URLs without a base. Bypass the typed deserialization via Request::response_type and a local LocalCombinedStatus that carries target_url as Option<String>; the JSON printer resolves it against the host URL before emitting.

Adds --json to fj pr status, producing a machine-readable record with pr, head_sha, state (combined CI state, following Forgejo's combined-status semantics), mergeable, merged, and statuses[] (context, state, description, target_url). Merged PRs additionally carry merged_by / merged_at. The --wait loop suppresses its incremental human-readable progress when paired with --json so only the final JSON record reaches stdout.

#FJ-2 State Done

`fj pr status <id>` crashed when the Forgejo API returned commit statuses whose `target_url` was relative (e.g. `/owner/repo/actions/runs/85/jobs/0`). The crash came from `forgejo_api::structs::CommitStatus::target_url` being typed `Option<url::Url>`, and the `url` crate rejecting relative URLs without a base. Bypass the typed deserialization via `Request::response_type` and a local `LocalCombinedStatus` that carries `target_url` as `Option<String>`; the JSON printer resolves it against the host URL before emitting. Adds `--json` to `fj pr status`, producing a machine-readable record with `pr`, `head_sha`, `state` (combined CI state, following Forgejo's combined-status semantics), `mergeable`, `merged`, and `statuses[]` (`context`, `state`, `description`, `target_url`). Merged PRs additionally carry `merged_by` / `merged_at`. The `--wait` loop suppresses its incremental human-readable progress when paired with `--json` so only the final JSON record reaches stdout. #FJ-2 State Done
`fj pr status <id>` crashed when the Forgejo API returned commit statuses whose `target_url` was relative (e.g. `/owner/repo/actions/runs/85/jobs/0`). The crash came from `forgejo_api::structs::CommitStatus::target_url` being typed `Option<url::Url>`, and the `url` crate rejecting relative URLs without a base. Bypass the typed deserialization via `Request::response_type` and a local `LocalCombinedStatus` that carries `target_url` as `Option<String>`; the JSON printer resolves it against the host URL before emitting.

Adds `--json` to `fj pr status`, producing a machine-readable record with `pr`, `head_sha`, `state` (combined CI state, following Forgejo's combined-status semantics), `mergeable`, `merged`, and `statuses[]` (`context`, `state`, `description`, `target_url`). Merged PRs additionally carry `merged_by` / `merged_at`. The `--wait` loop suppresses its incremental human-readable progress when paired with `--json` so only the final JSON record reaches stdout.

#FJ-2 State Done
Merge main into fix/pr-status-json-relative-url (FJ-2)
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 39s
Create release / Create release from merged PR (pull_request) Has been skipped
dd33e3326d
Resolve the conflict in crates/fj/src/prs.rs. main independently landed the FJ-2 work (relative-URL crash fix via fj_core's CommitStatusLenient, plus pr status --json) during the FJ-3 crate split, so the resolution adopts main's crate-split architecture wholesale and grafts back the one spec-justified behavior main lacked: pr status --json now resolves each status target_url against the host URL so consumers get absolute links (e.g. https://host/owner/repo/actions/runs/85), matching the FJ-2 example. main emitted the raw relative path. Relative values resolve against the host, already-absolute values pass through, empty strings drop to null.

Dropped the PR's local LocalCombinedStatus / LocalCommitStatus mirror types and FromResponse impl in favor of fj_core::prs::get_commit_statuses, and the merged-record merged_by / merged_at JSON fields the PR added (outside the FJ-2 acceptance criteria; would pull in time formatting features for no spec requirement). Combined top-level state keeps main's local computation, which follows the same Forgejo combined-status semantics the issue specifies.

#FJ-2
David merged commit 0ac836dfc8 into main 2026-05-28 19:44:25 +02:00
David deleted branch fix/pr-status-json-relative-url 2026-05-28 19:44:25 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/forgejo-cli!21
No description provided.