Commit ef75ea5
feat(rust): port queue status to native Rust (Phase 1.7)
The Rust binary now serves ``mergify queue status`` natively. The
Python implementation (``mergify_cli/queue/cli.py:status`` plus the
batch/scope/topology helpers it depended on) is removed in the
same PR — the port-and-delete rule we adopted in #1322 keeps a
single live copy of every command.
## What ports
``mergify queue status [-r REPO] [-t TOKEN] [-u URL] [-b BRANCH]
[--json]``:
1. Resolves repository / token / API URL via the shared
``mergify_queue::auth`` resolver introduced in #1352.
2. Fetches ``GET /v1/repos/<repo>/merge-queue/status``, optionally
with ``?branch=<branch>`` (URL-encoded via
``url::form_urlencoded::byte_serialize``).
3. With ``--json``: pretty-prints the raw response. The schema is
Mergify's API contract, not this CLI's, so we deserialize into
``serde_json::Value`` and emit verbatim — unknown fields and
future schema additions survive the round trip.
4. Without ``--json``: deserializes into a typed ``StatusView``
that uses ``#[serde(default)] Option<…>`` for every field the
Mergify API has historically treated as optional/nullable
(matches the port checklist from #1357), then renders a
header, an optional pause indicator, the batch tree (grouped
by scope when there is more than one), and the waiting-PR
list. Status icons (``● ◑ ◌ ✓ ✗ ◎ ⏳ ↻ ⏰ ❄``) and relative
times (``5m ago`` / ``~1h``) match the Python implementation.
## Rendering departures
Python used Rich's ``Tree`` for batches. The Rust port emits
flat indented text instead — same data, simpler rendering. Both
are line-oriented and round-trip cleanly through pipes; the
fancy box-drawing was visual sugar that didn't survive piping
anyway.
## Tests (24 new, in mergify-queue::status)
- ``build_path`` covers no-branch, branch, and URL-encoding of a
branch name with slashes + spaces (e.g. ``feature/foo bar``
becomes ``feature%2Ffoo+bar`` in the query).
- ``relative_time`` covers seconds / minutes / hours / days,
future prefix, and graceful empty-string return on a malformed
timestamp (matches Python's "degrade rather than fail").
- ``topological_sort`` covers parents-before-children ordering
and tolerance of ``parent_ids`` that reference missing batches.
- ``group_by_scope`` covers the ``[]`` → ``"default"`` fallback
and multi-scope batches appearing under each scope they claim.
- ``status_icon`` covers known + unknown codes.
- End-to-end wiremock tests: empty queue, paused queue, batches +
waiting PRs, multi-scope grouping, ``?branch=…`` query
threading, JSON-passthrough preserving an ``extra_field``,
and tolerance of a response that omits all optional fields.
## Wiring
- ``crates/mergify-queue/Cargo.toml``: adds ``chrono`` (relative
time math), ``indexmap`` (scope groups in insertion order),
promotes ``serde_json`` from dev to runtime (used for the
``serde_json::Value`` passthrough).
- ``crates/mergify-cli/src/main.rs``: registers the ``status``
subcommand under ``QueueSubcommand``, threads the
``--branch``/``--json`` flags, dispatches to
``mergify_queue::status::run``. Adds ``status`` to
``looks_native``.
- ``mergify_cli/queue/api.py``: removes ``QueueStatusResponse``,
``QueueBatch``, ``QueuePause``, ``QueueChecksSummary``,
``QueueBatchStatus``, ``QueuePullRequest``,
``QueuePullRequestAuthor``, and ``get_queue_status`` — all
now Rust-native. ``QueuePullResponse`` and friends stay for
the still-shimmed ``queue show`` (next phase).
- ``mergify_cli/queue/cli.py``: removes the ``@queue.command
status`` block and the helpers it owned (``STATUS_STYLES``,
``_status_text``, ``_batch_label``, ``_pr_label``,
``_topological_sort``, ``_group_batches_by_scope``,
``_print_batches``, ``_print_waiting_prs``).
``_relative_time`` stays — ``show`` still uses it.
- ``mergify_cli/tests/queue/test_cli.py``: deletes
``TestStatusCommand``, ``TestTopologicalSort``, and the
``_invoke_status`` helper. ``TestRelativeTime`` stays.
Workspace: 138 Rust tests green, 590 Python tests green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I8cebcd325f05173dfa41083da2ec6516a6ec3a3f1 parent 742d92c commit ef75ea5
8 files changed
Lines changed: 1072 additions & 614 deletions
File tree
- crates
- mergify-cli/src
- mergify-queue
- src
- mergify_cli
- queue
- tests/queue
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
92 | 102 | | |
93 | 103 | | |
94 | 104 | | |
| |||
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
107 | | - | |
| 117 | + | |
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
| |||
216 | 226 | | |
217 | 227 | | |
218 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
219 | 241 | | |
220 | 242 | | |
221 | 243 | | |
| |||
294 | 316 | | |
295 | 317 | | |
296 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
297 | 332 | | |
298 | 333 | | |
299 | 334 | | |
| |||
465 | 500 | | |
466 | 501 | | |
467 | 502 | | |
| 503 | + | |
| 504 | + | |
468 | 505 | | |
469 | 506 | | |
470 | 507 | | |
| |||
478 | 515 | | |
479 | 516 | | |
480 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | | - | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| 14 | + | |
12 | 15 | | |
0 commit comments