feat(rust): port queue show to native Rust#1399
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.
|
9b78873 to
e00f387
Compare
da5a658 to
0e20a86
Compare
Revision history
|
e00f387 to
c783f0f
Compare
0e20a86 to
65e243f
Compare
c783f0f to
d96bb5e
Compare
0d446e4 to
40a75b9
Compare
ca322fe to
bea6443
Compare
40a75b9 to
d258905
Compare
There was a problem hiding this comment.
Pull request overview
Ports mergify queue show <PR_NUMBER> from the Python Click implementation to the native Rust binary, and removes the now-redundant Python mergify_cli/queue/ package to keep a single source of truth for the queue command group.
Changes:
- Add native Rust implementation of
mergify queue showwith human +--jsonoutput modes and verbose rendering. - Extend the shared Rust HTTP client with
get_if_exists()(404 →None) to support “not in queue” as a caller branch. - Remove the Python
queuecommand implementation and its unit tests; update the remaining Python skill test to validate against the native binary’s command list.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
crates/mergify-queue/src/show.rs |
New Rust-native queue show command implementation + unit tests. |
crates/mergify-queue/src/lib.rs |
Exposes the new show module. |
crates/mergify-core/src/http.rs |
Adds Client::get_if_exists() and an internal 404→None request path. |
crates/mergify-cli/src/main.rs |
Wires queue show into clap parsing, native dispatch, and native command listing. |
mergify_cli/cli.py |
Removes registration of the Python queue Click group. |
mergify_cli/queue/cli.py |
Deleted: legacy Python queue commands including show rendering helpers. |
mergify_cli/queue/api.py |
Deleted: legacy Python API wrapper/types for queue show. |
mergify_cli/queue/__init__.py |
Removed as part of deleting the mergify_cli.queue package. |
mergify_cli/tests/queue/test_show.py |
Deleted: Python unit tests for queue show output and behaviors. |
mergify_cli/tests/queue/test_cli.py |
Deleted: Python unit tests for _relative_time helper (no longer in Python queue package). |
mergify_cli/tests/queue/test_skill.py |
Updates skill-command validation to rely solely on native command listing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d258905 to
b9688d1
Compare
2d08ea5 to
9bbe2bc
Compare
b9688d1 to
72c4bf3
Compare
The Rust binary now serves ``mergify queue show <PR_NUMBER>`` natively. The Python implementation (``mergify_cli/queue/cli.py:show`` plus the eight rendering helpers it depended on, plus ``mergify_cli/queue/api.py``) is removed in the same PR — the port-and-delete rule keeps a single live copy of every command. This is the last command in the ``queue`` group, so the whole ``mergify_cli/queue/`` Python package goes away. Closes the gap noted in #1380's commit message: ``mergify queue --help`` now lists ``show`` alongside ``pause`` / ``unpause`` / ``status``. ``mergify queue show <PR_NUMBER> [-v] [--json] [-r REPO] [-t TOKEN] [-u URL]``: 1. Resolves repository / token / API URL via the shared ``mergify_core::auth`` resolver. 2. Fetches ``GET /v1/repos/<repo>/merge-queue/pull/<pr_number>`` through the new ``HttpClient::get_if_exists`` helper. On 404 the command exits with ``MERGIFY_API_ERROR`` and the message ``PR #<n> is not in the merge queue``, matching the Python implementation. Other 4xx/5xx surface as normal API errors. 3. With ``--json``: pretty-prints the raw response. Schema is the Mergify API contract, so unknown fields survive verbatim. 4. Without ``--json``: renders the metadata block (position / priority / queue rule / queued / ETA), then a CI-state line and a checks section, then a conditions section. ``--verbose`` switches the checks summary to a full table and the conditions summary to a tree (``├── └── │ ``) instead of the compact ``N/M met`` summary with bullet-listed failures. New plumbing in ``mergify-core::http``: - ``Client::get_if_exists<T>(&path) -> Result<Option<T>, _>`` — GET that returns ``None`` on 404. Mirrors ``delete_if_exists`` for read-only endpoints where "not found" is a meaningful caller branch rather than a server failure. Reuses the same retry policy, bearer-auth injection, and flavor-aware error mapping as ``get`` / ``post`` / ``put``. Tests: - 7 new unit tests in ``crates/mergify-queue/src/show.rs``: compact metadata + checks summary + failing-conditions block; verbose checks table + conditions tree; JSON passthrough with a synthetic ``future_field`` to verify unknown fields survive; 404 → ``MergifyApi`` error with the right message; missing ``mergeability_check`` falls through to "Waiting for mergeability check..."; condition-group summarization (two labels joined with ``or``; truncation at 3+ labels); aggregator recursion (``any of`` / ``all of`` / ``not`` falls through to the first leaf). Wiring: - ``crates/mergify-cli/src/main.rs``: adds ``Show(ShowCliArgs)`` to ``QueueSubcommand``, dispatch to ``mergify_queue::show::run``. Adds ``("queue", "show")`` to ``NATIVE_COMMANDS``. ``ShowCliArgs`` carries the positional ``pr_number: u64`` plus ``--verbose`` and ``--json`` flags. Python deletions: - ``mergify_cli/queue/__init__.py`` / ``cli.py`` / ``api.py``: removed entirely. The whole package goes away — all four ``queue`` subcommands are now Rust-native. - ``mergify_cli/cli.py``: drops the ``from mergify_cli.queue import cli as queue_cli_mod`` import and the ``cli.add_command(queue_cli_mod.queue)`` call. - ``mergify_cli/tests/queue/test_cli.py``: deleted entirely (it only covered ``_relative_time``, which lives in ``mergify-tui::time`` now). - ``mergify_cli/tests/queue/test_show.py``: deleted entirely. - ``mergify_cli/tests/queue/test_skill.py``: drops the click import; the skill-reference check now consults the binary alone (no parallel click-command list to merge). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I6c265303a37642529dbbcef6f255eb429407a1d2
72c4bf3 to
9d67b7f
Compare
9bbe2bc to
85a46d3
Compare
The Rust binary now serves
mergify queue show <PR_NUMBER>natively. The Python implementation
(
mergify_cli/queue/cli.py:showplus the eight renderinghelpers it depended on, plus
mergify_cli/queue/api.py) isremoved in the same PR — the port-and-delete rule keeps a single
live copy of every command.
This is the last command in the
queuegroup, so the wholemergify_cli/queue/Python package goes away. Closes the gapnoted in #1380's commit message:
mergify queue --helpnowlists
showalongsidepause/unpause/status.mergify queue show <PR_NUMBER> [-v] [--json] [-r REPO] [-t TOKEN] [-u URL]:mergify_core::authresolver.GET /v1/repos/<repo>/merge-queue/pull/<pr_number>through the new
HttpClient::get_if_existshelper. On 404the command exits with
MERGIFY_API_ERRORand the messagePR #<n> is not in the merge queue, matching the Pythonimplementation. Other 4xx/5xx surface as normal API errors.
--json: pretty-prints the raw response. Schema is theMergify API contract, so unknown fields survive verbatim.
--json: renders the metadata block (position /priority / queue rule / queued / ETA), then a CI-state line
and a checks section, then a conditions section.
--verboseswitches the checks summary to a full table andthe conditions summary to a tree (
├── └── │) insteadof the compact
N/M metsummary with bullet-listedfailures.
New plumbing in
mergify-core::http:Client::get_if_exists<T>(&path) -> Result<Option<T>, _>—GET that returns
Noneon 404. Mirrorsdelete_if_existsfor read-only endpoints where "not found"is a meaningful caller branch rather than a server failure.
Reuses the same retry policy, bearer-auth injection, and
flavor-aware error mapping as
get/post/put.Tests:
crates/mergify-queue/src/show.rs:compact metadata + checks summary + failing-conditions block;
verbose checks table + conditions tree; JSON passthrough with
a synthetic
future_fieldto verify unknown fields survive;404 →
MergifyApierror with the right message; missingmergeability_checkfalls through to "Waiting formergeability check..."; condition-group summarization (two
labels joined with
or; truncation at 3+ labels);aggregator recursion (
any of/all of/notfallsthrough to the first leaf).
Wiring:
crates/mergify-cli/src/main.rs: addsShow(ShowCliArgs)to
QueueSubcommand, dispatch tomergify_queue::show::run. Adds("queue", "show")toNATIVE_COMMANDS.ShowCliArgscarries the positionalpr_number: u64plus--verboseand--jsonflags.Python deletions:
mergify_cli/queue/__init__.py/cli.py/api.py:removed entirely. The whole package goes away — all four
queuesubcommands are now Rust-native.mergify_cli/cli.py: drops thefrom mergify_cli.queue import cli as queue_cli_modimportand the
cli.add_command(queue_cli_mod.queue)call.mergify_cli/tests/queue/test_cli.py: deleted entirely (itonly covered
_relative_time, which lives inmergify-tui::timenow).mergify_cli/tests/queue/test_show.py: deleted entirely.mergify_cli/tests/queue/test_skill.py: drops the clickimport; the skill-reference check now consults the binary
alone (no parallel click-command list to merge).
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Depends-On: #1408