refactor(core): migrate issues/prs/org API logic into fj-core (FJ-12) #14

Merged
David merged 2 commits from refactor/migrate-complex-areas-fj-12 into main 2026-05-25 18:27:23 +02:00
Owner

What

Phase 4c of FJ-3 (subtask of FJ-8): migrate the complex command areas (issues, prs, org, org/team) into fj-core operations, following the Phase 4 pattern already applied to repo/release/user/actions in FJ-11.

Each forgejo-api call moved into a pub async fn in fj-core that returns the forgejo-api struct; each binary command path is reduced to parse-args then call then render. There are no direct forgejo-api calls left in crates/fj/src/{issues,prs,org,org/team}.rs.

New fj-core modules

  • fj_core::issues: issue/comment CRUD, templates, issue config, label_names_to_ids / maybe_label_names_to_ids, and the API-mutating part of edit_labels.
  • fj_core::prs: PR get/list/create/merge, files/commits/reviews/review-comments, diff download, compare, the streaming find_pr_from_branch, the lenient combined-status fetch, and the PR-template fetch.
  • fj_core::org and fj_core::org::team: org get/list/create/edit, members/visibility, labels, repos, and the full team surface.

Label helpers

Per the task spec, the API-mutating part of edit_labels (resolve names, add, remove) moved to fj_core::issues::edit_labels, which returns the unknown label names. render_label* and the "doesn't exist" message stay in crates/fj/src/main.rs.

FJ-2 preserved

The pr status --json path is preserved verbatim: the lenient combined-status types (CommitStatusLenient, CombinedStatusLenient) and the manual pagination in get_commit_statuses moved into fj_core::prs, with CommitStatusLenient exported so the binary's JSON and text renderers reuse it.

Scope note

crates/fj/src/issues/template.rs::get_template_file (issue templates) is left untouched: it is Phase 3 scope (not in FJ-12's module list) and the documented exception that bundles the network fetch with the interactive $EDITOR loop. The analogous PR-template fetch was in prs.rs (in scope) and moved to fj_core::prs::get_template_file.

Deps

fj-core gains futures, serde_json, and soft_assert as direct deps; all are already present transitively (futures via comrak), so no new crates enter the tree. The fj-core dependency tree stays free of clap, crossterm, and fluent.

Verification

  • cargo build --locked (workspace): passes.
  • cargo tree -p fj-core -e normal | grep -E 'clap|crossterm|fluent': prints nothing. (comrak remains a direct, documented dep; the issue's grep listed it but fj-core has depended on it since before this PR.)
  • cargo fmt --check: clean.
  • cargo clippy --all-targets -- -D warnings: clean.
  • cargo build --all-targets and cargo test: pass.
  • check-docker (builder-stage Docker compile) was not run here (no Docker/network in this environment); the cargo equivalents all pass.

Refs FJ-12.

## What Phase 4c of FJ-3 (subtask of FJ-8): migrate the complex command areas (`issues`, `prs`, `org`, `org/team`) into `fj-core` operations, following the Phase 4 pattern already applied to repo/release/user/actions in FJ-11. Each `forgejo-api` call moved into a `pub async fn` in `fj-core` that returns the `forgejo-api` struct; each binary command path is reduced to parse-args then call then render. There are no direct `forgejo-api` calls left in `crates/fj/src/{issues,prs,org,org/team}.rs`. ## New fj-core modules - `fj_core::issues`: issue/comment CRUD, templates, issue config, `label_names_to_ids` / `maybe_label_names_to_ids`, and the API-mutating part of `edit_labels`. - `fj_core::prs`: PR get/list/create/merge, files/commits/reviews/review-comments, diff download, compare, the streaming `find_pr_from_branch`, the lenient combined-status fetch, and the PR-template fetch. - `fj_core::org` and `fj_core::org::team`: org get/list/create/edit, members/visibility, labels, repos, and the full team surface. ## Label helpers Per the task spec, the API-mutating part of `edit_labels` (resolve names, add, remove) moved to `fj_core::issues::edit_labels`, which returns the unknown label names. `render_label*` and the "doesn't exist" message stay in `crates/fj/src/main.rs`. ## FJ-2 preserved The `pr status --json` path is preserved verbatim: the lenient combined-status types (`CommitStatusLenient`, `CombinedStatusLenient`) and the manual pagination in `get_commit_statuses` moved into `fj_core::prs`, with `CommitStatusLenient` exported so the binary's JSON and text renderers reuse it. ## Scope note `crates/fj/src/issues/template.rs::get_template_file` (issue templates) is left untouched: it is Phase 3 scope (not in FJ-12's module list) and the documented exception that bundles the network fetch with the interactive `$EDITOR` loop. The analogous PR-template fetch was in `prs.rs` (in scope) and moved to `fj_core::prs::get_template_file`. ## Deps fj-core gains `futures`, `serde_json`, and `soft_assert` as direct deps; all are already present transitively (futures via comrak), so no new crates enter the tree. The fj-core dependency tree stays free of clap, crossterm, and fluent. ## Verification - `cargo build --locked` (workspace): passes. - `cargo tree -p fj-core -e normal | grep -E 'clap|crossterm|fluent'`: prints nothing. (`comrak` remains a direct, documented dep; the issue's grep listed it but `fj-core` has depended on it since before this PR.) - `cargo fmt --check`: clean. - `cargo clippy --all-targets -- -D warnings`: clean. - `cargo build --all-targets` and `cargo test`: pass. - `check-docker` (builder-stage Docker compile) was not run here (no Docker/network in this environment); the cargo equivalents all pass. Refs FJ-12.
refactor(core): migrate issues/prs/org API logic into fj-core (FJ-12)
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 37s
5d758b6dd5
Phase 4c of FJ-3: the complex command areas (issues, prs, org, org/team) now follow the established Phase 4 pattern. Each `forgejo-api` call moved into a `pub async fn` in `fj-core` (`fj_core::issues`, `fj_core::prs`, `fj_core::org`, `fj_core::org::team`) that returns the `forgejo-api` struct, and each binary module's command path is reduced to parse-args then call then render. No direct `forgejo-api` calls remain in `crates/fj/src/{issues,prs,org,org/team}.rs`.

The shared label helpers were split per the task spec: the API-mutating part of `edit_labels` (resolve names, add, remove) moved to `fj_core::issues::edit_labels`, which returns the unknown label names; `render_label*` and the "doesn't exist" message stay in the binary. `label_names_to_ids` / `maybe_label_names_to_ids` moved to `fj_core::issues`.

The FJ-2 `pr status --json` path is preserved: the lenient combined-status types (`CommitStatusLenient`, `CombinedStatusLenient`) and the manual pagination in `get_commit_statuses` moved verbatim into `fj_core::prs`, with `CommitStatusLenient` exported so the binary's JSON/text renderers reuse it. The streaming `find_pr_from_branch` and the org/team `find_by_name` / `find_label_by_name` helpers moved intact (`futures` is already in fj-core's tree via comrak).

The PR-template network fetch (`get_template_file`) moved to `fj_core::prs`. The analogous issue-template fetch in `crates/fj/src/issues/template.rs` is left in the binary unchanged: it is Phase 3 scope (not in FJ-12's module list) and the documented exception that bundles the network fetch with the interactive `$EDITOR` loop.

fj-core gains `futures`, `serde_json`, and `soft_assert` as direct deps (all already present transitively); its dependency tree stays free of clap, crossterm, and fluent. Interactive `$EDITOR`/prompt flows and all `git2` work stay in the binary.

#FJ-12

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merge branch 'main' into refactor/migrate-complex-areas-fj-12
All checks were successful
Create release / Create release from merged PR (pull_request) Has been skipped
Check / fmt + clippy + build + tests (pull_request) Successful in 38s
5a2e6beaf1
David merged commit bf95620e0c into main 2026-05-25 18:27:23 +02:00
David deleted branch refactor/migrate-complex-areas-fj-12 2026-05-25 18:27:23 +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!14
No description provided.