Add --label and --author filters to pr list #130

Merged
stephen merged 1 commit from feat/113-pr-list-filters into main 2026-06-11 01:10:28 +00:00
Owner

Closes the pr list filter gap from rasterstate/fj#113: fj pr list
filtered by state only, while fj issue list already takes
--label/--assignee.

What changed

  • --label NAME (repeatable / comma-separated) and --author USERNAME
    on fj pr list, threaded through pull_core::ListOptions and its
    query builder.
  • The Forgejo /pulls endpoint filters labels by ID, not name, so
    --label resolves names to IDs up front via the existing
    api::label::resolve_names_to_ids. An unknown name fails with a clear
    no label named '...'.
  • --author maps to the poster query param, which returns a clear
    400 user does not exist on an unknown login.
  • Filters AND together with each other and with --state, and compose
    with --json and --paginate (the param builder is shared across
    both the paged and capped fetch paths).

On --assignee

The issue also asked for --assignee, but the Forgejo /pulls endpoint
(verified against the live forge, v15.0.2) has no assignee filter:
assignee/assigned_by are silently ignored and the full list comes
back. Assignee filtering for PRs only exists on the /issues?type=pulls
endpoint, whose payload has no head/base, so routing through it would
blank out the BRANCHES column the PR table renders. Rather than ship a
silently-broken flag or change the list's data source, --assignee is
left out of this PR.

Tests

  • pull_list_sends_label_ids_and_poster: asserts labels/poster
    query params are sent.
  • pull_list_omits_filter_params_when_unset: asserts no labels/poster
    params when filters are empty/unset.
  • list_parses_label_and_author_filters: clap parsing for the new flags.

cargo fmt --check, clippy (-D warnings), and cargo test --all all pass.

Closes the `pr list` filter gap from rasterstate/fj#113: `fj pr list` filtered by state only, while `fj issue list` already takes `--label`/`--assignee`. ## What changed - `--label NAME` (repeatable / comma-separated) and `--author USERNAME` on `fj pr list`, threaded through `pull_core::ListOptions` and its query builder. - The Forgejo `/pulls` endpoint filters labels by **ID**, not name, so `--label` resolves names to IDs up front via the existing `api::label::resolve_names_to_ids`. An unknown name fails with a clear `no label named '...'`. - `--author` maps to the `poster` query param, which returns a clear `400 user does not exist` on an unknown login. - Filters AND together with each other and with `--state`, and compose with `--json` and `--paginate` (the param builder is shared across both the paged and capped fetch paths). ## On --assignee The issue also asked for `--assignee`, but the Forgejo `/pulls` endpoint (verified against the live forge, v15.0.2) has **no assignee filter**: `assignee`/`assigned_by` are silently ignored and the full list comes back. Assignee filtering for PRs only exists on the `/issues?type=pulls` endpoint, whose payload has no `head`/`base`, so routing through it would blank out the BRANCHES column the PR table renders. Rather than ship a silently-broken flag or change the list's data source, `--assignee` is left out of this PR. ## Tests - `pull_list_sends_label_ids_and_poster`: asserts `labels`/`poster` query params are sent. - `pull_list_omits_filter_params_when_unset`: asserts no `labels`/`poster` params when filters are empty/unset. - `list_parses_label_and_author_filters`: clap parsing for the new flags. cargo fmt --check, clippy (-D warnings), and cargo test --all all pass.
Add --label and --author filters to pr list
All checks were successful
ci / check (pull_request) Successful in 9m52s
ci / live-e2e (pull_request) Successful in 1m48s
ci / coverage (pull_request) Successful in 2m0s
2371e9c51e
`fj pr list` filtered by state only, while `fj issue list` already
accepts --label/--assignee. Thread label and author filters through
`pull_core::ListOptions` and its query builder.

The Forgejo /pulls endpoint filters labels by ID (not name), so --label
resolves names to IDs via the existing label resolver up front; an
unknown name fails with a clear "no label named ..." error. --author
maps to the `poster` query param, which 400s clearly on an unknown user.

Forgejo's /pulls endpoint has no assignee filter (only the issues
endpoint does, via assigned_by), so --assignee is intentionally left
out; filtering PRs by assignee would require routing through the issues
endpoint and giving up the branch columns the PR table renders.

Filters AND together with each other and with --state, and compose with
--json and --paginate. Wiremock coverage asserts the new query params
are sent, and are omitted when unset.

Fixes rasterstate/fj#113
Sign in to join this conversation.
No reviewers
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
rasterstate/fj!130
No description provided.