feat(rust): port queue status to native Rust#1359
Conversation
|
This pull request is part of a Mergify stack:
|
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
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
4be1b66 to
d75104b
Compare
2958801 to
5c930de
Compare
5c930de to
6080692
Compare
542af35 to
a630c92
Compare
a630c92 to
7eb3c64
Compare
6080692 to
76f551a
Compare
7eb3c64 to
37735a7
Compare
76f551a to
1371b4e
Compare
37735a7 to
f706a9a
Compare
1371b4e to
cefce9c
Compare
cefce9c to
e7ff17e
Compare
There was a problem hiding this comment.
Pull request overview
Ports mergify queue status from the Python shim to the native Rust binary, removing the Python implementation to keep a single source of truth and introducing a small shared “TUI primitives” crate for consistent human-readable rendering across future ports.
Changes:
- Add a native Rust implementation of
queue status(human output +--jsonpassthrough) and wire it into the Rust CLI dispatcher. - Introduce the new
mergify-tuicrate (theme/color handling, relative-time formatting, tree characters) and use it frommergify-queue. - Remove the Python
queue statuscommand + its API/types and delete the Python CLI tests that were specific to that implementation.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
mergify_cli/tests/queue/test_skill.py |
Marks status as Rust-native for skill validation. |
mergify_cli/tests/queue/test_cli.py |
Removes Python queue status tests; keeps _relative_time tests. |
mergify_cli/queue/cli.py |
Deletes Python queue status implementation and helper renderers. |
mergify_cli/queue/api.py |
Removes Python get_queue_status + related TypedDicts. |
crates/mergify-tui/src/lib.rs |
Exposes shared TUI primitives for ported commands. |
crates/mergify-tui/src/theme.rs |
Adds Theme with TTY/NO_COLOR detection + named styles. |
crates/mergify-tui/src/time.rs |
Adds coarse relative_time formatter. |
crates/mergify-tui/src/tree.rs |
Adds box-drawing constants and branch_chars(). |
crates/mergify-tui/Cargo.toml |
Defines the new mergify-tui crate/deps. |
crates/mergify-queue/src/status.rs |
Implements native queue status + unit/e2e tests. |
crates/mergify-queue/src/lib.rs |
Exports the new status module and updates module docs. |
crates/mergify-queue/Cargo.toml |
Adds deps required by status and mergify-tui. |
crates/mergify-cli/src/main.rs |
Adds native dispatch + clap wiring for queue status. |
Cargo.lock |
Locks new crate dependencies (chrono, iana-time-zone, etc.). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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. This change also introduces the ``mergify-tui`` crate. The colored-tree rendering primitives are written there from the start (``Theme`` + relative-time formatter + box-drawing characters) rather than inlined in ``status.rs`` and extracted later — they're general-purpose and will be needed by every command with structured human output (``queue show``, ``freeze list``, future 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 (``● ◑ ◌ ✓ ✗ ◎ ⏳ ↻ ⏰ ❄``), tree characters (``├── └── │ ``), and relative times (``5m ago`` / ``~1h``) match the Python implementation. The ``mergify-tui`` crate has three modules: - ``theme``: ``Theme`` struct with TTY/``NO_COLOR``-aware enable/disable. Pre-built named styles (``bold``, ``dim``, ``cyan``/``green``/``red``/``yellow``/``magenta``, ``warn``) plus a ``fg(AnsiColor)`` helper for domain-specific palettes. ``Theme::detect`` is the production constructor; ``Theme::new(enabled)`` is for tests. - ``time``: ``relative_time(iso, now, future)`` — coarse ``Ns``/``Nm``/``Nh``/``Nd`` formatter mirroring the Python CLI's ``_relative_time``. Empty string on parse failure so a malformed timestamp doesn't abort the surrounding render. - ``tree``: Unicode box-drawing constants (``BRANCH``, ``LAST_BRANCH``, ``CONTINUATION``, ``LAST_CONTINUATION``) plus ``branch_chars(is_last)`` to pick both prefixes for a row in one call. Tests: - ``mergify-tui``: 11 tests (theme on/off, relative-time units + parse failure + future prefix, tree-character pairing). - ``build_path`` covers no-branch, branch, and URL-encoding of a branch name with slashes + spaces. - ``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. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I8cebcd325f05173dfa41083da2ec6516a6ec3a3f
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.
This change also introduces the
mergify-tuicrate. Thecolored-tree rendering primitives are written there from the
start (
Theme+ relative-time formatter + box-drawingcharacters) rather than inlined in
status.rsand extractedlater — they're general-purpose and will be needed by every
command with structured human output (
queue show,freeze list, future ports).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 (
● ◑ ◌ ✓ ✗ ◎ ⏳ ↻ ⏰ ❄), treecharacters (
├── └── │), and relative times(
5m ago/~1h) match the Python implementation.The
mergify-tuicrate has three modules:theme:Themestruct with TTY/NO_COLOR-awareenable/disable. Pre-built named styles (
bold,dim,cyan/green/red/yellow/magenta,warn)plus a
fg(AnsiColor)helper for domain-specific palettes.Theme::detectis the production constructor;Theme::new(enabled)is for tests.time:relative_time(iso, now, future)— coarseNs/Nm/Nh/Ndformatter mirroring the PythonCLI's
_relative_time. Empty string on parse failure so amalformed timestamp doesn't abort the surrounding render.
tree: Unicode box-drawing constants (BRANCH,LAST_BRANCH,CONTINUATION,LAST_CONTINUATION) plusbranch_chars(is_last)to pick both prefixes for a row inone call.
Tests:
mergify-tui: 11 tests (theme on/off, relative-time units +parse failure + future prefix, tree-character pairing).
build_pathcovers no-branch, branch, and URL-encoding of abranch name with slashes + spaces.
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.waiting PRs, multi-scope grouping,
?branch=…querythreading, JSON-passthrough preserving an
extra_field,and tolerance of a response that omits all optional fields.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Depends-On: #1409