You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(rust): port queue pause and unpause to native Rust (Phase 1.5)
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
0 commit comments