feat(rust): port queue status to native Rust#1359
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced May 5, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
ef75ea5 to
d733d15
Compare
742d92c to
839ea5a
Compare
Member
Author
Revision history
|
d733d15 to
aa25245
Compare
aa25245 to
53d4832
Compare
53d4832 to
e7ad85a
Compare
3df5705 to
0349b1d
Compare
0349b1d to
c3fc948
Compare
e7ad85a to
4be1b66
Compare
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. ``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. 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. - ``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. - ``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: I8cebcd325f05173dfa41083da2ec6516a6ec3a3f
4be1b66 to
d75104b
Compare
c3fc948 to
6421363
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Rust binary now serves
mergify queue statusnatively. ThePython implementation (
mergify_cli/queue/cli.py:statusplus thebatch/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.
mergify queue status [-r REPO] [-t TOKEN] [-u URL] [-b BRANCH] [--json]:mergify_queue::authresolver introduced in feat(rust): port queue pause and unpause to native Rust #1352.GET /v1/repos/<repo>/merge-queue/status, optionallywith
?branch=<branch>(URL-encoded viaurl::form_urlencoded::byte_serialize).--json: pretty-prints the raw response. The schema isMergify's API contract, not this CLI's, so we deserialize into
serde_json::Valueand emit verbatim — unknown fields andfuture schema additions survive the round trip.
--json: deserializes into a typedStatusViewthat uses
#[serde(default)] Option<…>for every field theMergify API has historically treated as optional/nullable
(matches the port checklist from docs(port): add port review checklist for HTTP/test/UX parity pitfalls #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 relativetimes (
5m ago/~1h) match the Python implementation.Python used Rich's
Treefor batches. The Rust port emitsflat 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.
build_pathcovers no-branch, branch, and URL-encoding of abranch name with slashes + spaces (e.g.
feature/foo barbecomes
feature%2Ffoo+barin the query).relative_timecovers seconds / minutes / hours / days,future prefix, and graceful empty-string return on a malformed
timestamp (matches Python's "degrade rather than fail").
topological_sortcovers parents-before-children orderingand tolerance of
parent_idsthat reference missing batches.group_by_scopecovers the[]→"default"fallbackand multi-scope batches appearing under each scope they claim.
status_iconcovers known + unknown codes.End-to-end wiremock tests: empty queue, paused queue, batches +
waiting PRs, multi-scope grouping,
?branch=…querythreading, JSON-passthrough preserving an
extra_field,and tolerance of a response that omits all optional fields.
crates/mergify-queue/Cargo.toml: addschrono(relativetime math),
indexmap(scope groups in insertion order),promotes
serde_jsonfrom dev to runtime (used for theserde_json::Valuepassthrough).crates/mergify-cli/src/main.rs: registers thestatussubcommand under
QueueSubcommand, threads the--branch/--jsonflags, dispatches tomergify_queue::status::run. Addsstatustolooks_native.mergify_cli/queue/api.py: removesQueueStatusResponse,QueueBatch,QueuePause,QueueChecksSummary,QueueBatchStatus,QueuePullRequest,QueuePullRequestAuthor, andget_queue_status— allnow Rust-native.
QueuePullResponseand friends stay forthe still-shimmed
queue show(next phase).mergify_cli/queue/cli.py: removes the@queue.command statusblock 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_timestays —showstill uses it.mergify_cli/tests/queue/test_cli.py: deletesTestStatusCommand,TestTopologicalSort, and the_invoke_statushelper.TestRelativeTimestays.Workspace: 138 Rust tests green, 590 Python tests green.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Depends-On: #1353