refactor(core): migrate issues/prs/org API logic into fj-core (FJ-12) #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor/migrate-complex-areas-fj-12"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Phase 4c of FJ-3 (subtask of FJ-8): migrate the complex command areas (
issues,prs,org,org/team) intofj-coreoperations, following the Phase 4 pattern already applied to repo/release/user/actions in FJ-11.Each
forgejo-apicall moved into apub async fninfj-corethat returns theforgejo-apistruct; each binary command path is reduced to parse-args then call then render. There are no directforgejo-apicalls left incrates/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 ofedit_labels.fj_core::prs: PR get/list/create/merge, files/commits/reviews/review-comments, diff download, compare, the streamingfind_pr_from_branch, the lenient combined-status fetch, and the PR-template fetch.fj_core::organdfj_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 tofj_core::issues::edit_labels, which returns the unknown label names.render_label*and the "doesn't exist" message stay incrates/fj/src/main.rs.FJ-2 preserved
The
pr status --jsonpath is preserved verbatim: the lenient combined-status types (CommitStatusLenient,CombinedStatusLenient) and the manual pagination inget_commit_statusesmoved intofj_core::prs, withCommitStatusLenientexported 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$EDITORloop. The analogous PR-template fetch was inprs.rs(in scope) and moved tofj_core::prs::get_template_file.Deps
fj-core gains
futures,serde_json, andsoft_assertas 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. (comrakremains a direct, documented dep; the issue's grep listed it butfj-corehas depended on it since before this PR.)cargo fmt --check: clean.cargo clippy --all-targets -- -D warnings: clean.cargo build --all-targetsandcargo 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.
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>