feat(rust): port queue pause and unpause to native Rust (Phase 1.5)#1301
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Apr 23, 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.
|
fac593c to
c9705cd
Compare
Member
Author
Revision history
|
Two queue commands in one PR — both are idempotent one-shot API
calls that share the same auth + repository resolution. Pause
exercises the new PUT method; unpause exercises the new
DELETE-with-status-check method. Together they add 5 commands to
``native`` status (3 config + scopes-send + pause + unpause = 6 of
30 commands native).
## ``queue pause``
PUTs ``{"reason": "..."}`` to
``/v1/repos/<repo>/merge-queue/pause``, prints a confirmation line
with the reason and timestamp.
Safety rails match Python:
- ``--yes-i-am-sure`` skips confirmation outright.
- Interactive (TTY): prompts "Proceed? [y/N]". Anything other than
``y``/``yes`` aborts as a generic error.
- Non-interactive without the flag: refuses with INVALID_STATE
(exit 7), matching Python's
``raise SystemExit(ExitCode.INVALID_STATE)``.
``--reason`` has a 255-char cap enforced by clap's ``value_parser``
— bad input exits 2.
## ``queue unpause``
DELETEs the same path. On 404 the API is telling us the queue
wasn't paused, so the command prints "Queue is not currently
paused" and exits MERGIFY_API_ERROR (matches Python). On 2xx it
prints "Queue resumed." and exits 0.
## HttpClient additions
Two new methods on ``mergify_core::HttpClient``:
- ``put<B, T>(path, body) -> Result<T, CliError>`` — mirror of
``post``, different verb.
- ``delete_if_exists(path) -> Result<DeleteOutcome, CliError>`` —
returns ``Deleted`` on 2xx, ``NotFound`` on 404, errors on any
other non-success status. Lets commands like ``unpause`` give
a friendlier 404 message without parsing error strings.
## Shared auth helpers
The ``resolve_token`` / ``resolve_api_url`` / ``resolve_repository``
trio is duplicated into ``mergify_queue::auth``. That's now three
copies in the tree (config simulate, ci scopes-send, queue). A
follow-up PR factors them into ``mergify_core::auth`` as soon as
a fourth command needs them.
## Tests
5 new unit tests in the queue crate:
- ``parse_reason`` accepts short strings and rejects > 255 chars
- ``run`` pauses and prints the API-returned reason + timestamp
- ``run`` prints "Queue resumed" on 2xx
- ``run`` errors with MERGIFY_API_ERROR on 404 carrying the
"not currently paused" message
End-to-end smoke tested three paths:
``queue pause --reason X -r owner/repo`` → exit 8 (missing token),
``queue unpause -r owner/repo`` → exit 8 (missing token),
``echo n | queue pause --reason X`` → exit 7 (non-TTY, no --sure).
``PORT_STATUS.toml`` flips both ``queue pause`` and ``queue
unpause`` to ``native``. Binary: 8.4 MB → 8.5 MB. 56 Rust tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: Idba6fa38caf403fd5f4184cda462b5f7c1eb3ebf
0bbac0d to
5d204df
Compare
c9705cd to
9117fc7
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.
Two queue commands in one PR — both are idempotent one-shot API
calls that share the same auth + repository resolution. Pause
exercises the new PUT method; unpause exercises the new
DELETE-with-status-check method. Together they add 5 commands to
nativestatus (3 config + scopes-send + pause + unpause = 6 of30 commands native).
queue pausePUTs
{"reason": "..."}to/v1/repos/<repo>/merge-queue/pause, prints a confirmation linewith the reason and timestamp.
Safety rails match Python:
--yes-i-am-sureskips confirmation outright.y/yesaborts as a generic error.(exit 7), matching Python's
raise SystemExit(ExitCode.INVALID_STATE).--reasonhas a 255-char cap enforced by clap'svalue_parser— bad input exits 2.
queue unpauseDELETEs the same path. On 404 the API is telling us the queue
wasn't paused, so the command prints "Queue is not currently
paused" and exits MERGIFY_API_ERROR (matches Python). On 2xx it
prints "Queue resumed." and exits 0.
HttpClient additions
Two new methods on
mergify_core::HttpClient:put<B, T>(path, body) -> Result<T, CliError>— mirror ofpost, different verb.delete_if_exists(path) -> Result<DeleteOutcome, CliError>—returns
Deletedon 2xx,NotFoundon 404, errors on anyother non-success status. Lets commands like
unpausegivea friendlier 404 message without parsing error strings.
Shared auth helpers
The
resolve_token/resolve_api_url/resolve_repositorytrio is duplicated into
mergify_queue::auth. That's now threecopies in the tree (config simulate, ci scopes-send, queue). A
follow-up PR factors them into
mergify_core::authas soon asa fourth command needs them.
Tests
5 new unit tests in the queue crate:
parse_reasonaccepts short strings and rejects > 255 charsrunpauses and prints the API-returned reason + timestamprunprints "Queue resumed" on 2xxrunerrors with MERGIFY_API_ERROR on 404 carrying the"not currently paused" message
End-to-end smoke tested three paths:
queue pause --reason X -r owner/repo→ exit 8 (missing token),queue unpause -r owner/repo→ exit 8 (missing token),echo n | queue pause --reason X→ exit 7 (non-TTY, no --sure).PORT_STATUS.tomlflips bothqueue pauseandqueue unpausetonative. Binary: 8.4 MB → 8.5 MB. 56 Rust tests.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Depends-On: #1300