feat(rust): port freeze create/update/delete to native Rust#1437
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. 🔴 👀 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.
|
be2b24a to
f0eb260
Compare
Revision history
|
f0eb260 to
56f3cf1
Compare
414a70b to
8106d1c
Compare
56f3cf1 to
50fcb0d
Compare
7aefa73 to
622f895
Compare
1ac4b0d to
a8fc711
Compare
622f895 to
032f043
Compare
032f043 to
fcc43ed
Compare
fcc43ed to
a2bd0dd
Compare
d82958d to
8f0b96b
Compare
|
@jd this pull request is now in conflict 😩 |
Round-trip the three remaining freeze mutations: - `freeze create` — `POST /v1/repos/<r>/scheduled_freeze` with the Python `CreateScheduledFreezePayload` shape: `start`/`end` always present (null for open-ended emergency freezes), `matching_conditions`/`exclude_conditions` keys omitted when the user passed no `-c`/`-e` flags. When `--timezone` is left off, falls back to `iana-time-zone::get_timezone()` — same role as Python's `tzlocal.get_localzone_name()`. - `freeze update` — `PATCH /v1/repos/<r>/scheduled_freeze/<id>` with skip-if-none on every field so PATCH semantics work correctly: a flag the user didn't pass doesn't touch the stored field. - `freeze delete` — `POST /v1/repos/<r>/scheduled_freeze/<id>/delete` with `delete_reason` in the body only when supplied (the API requires it for active freezes; the CLI lets the server reject a missing reason rather than pre-validating). Adds `Client::patch` on the core HTTP client, a shared `mergify-freeze::common` module (wire-format struct, naive-DT parser, system-timezone detection, per-freeze human printer used by `create` and `update`), and `iana-time-zone` as a new dependency. The Python implementation of each command is left in place but no longer reachable via the binary, since clap now dispatches the whole freeze group natively. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Change-Id: I653dbf47080f439f8c3500a7a526e46d707fc639
a2bd0dd to
659f960
Compare
There was a problem hiding this comment.
Pull request overview
Ports the remaining mergify freeze mutations (create, update, delete) from the Python implementation to native Rust, aligning wire formats and human output with the existing CLI behavior while extending the core HTTP client with a PATCH verb.
Changes:
- Add native Rust implementations for
freeze create/update/deleteplus a sharedcommonmodule for wire structs, datetime parsing, timezone detection, and human formatting. - Extend
mergify-coreHTTP client withClient::patchand route freeze subcommands through Rust clap dispatch (no Python fallback). - Add
iana-time-zone(timezone detection) and a directchronodependency tomergify-clifor typed datetime CLI args.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mergify-freeze/src/create.rs | Implements freeze create POST payload + human output and wiremock tests. |
| crates/mergify-freeze/src/update.rs | Implements freeze update PATCH payload with optional fields + tests for omitted fields. |
| crates/mergify-freeze/src/delete.rs | Implements freeze delete POST-to-/delete semantics + tests for optional reason body. |
| crates/mergify-freeze/src/common.rs | Introduces shared wire struct, datetime parsing, timezone detection, and freeze pretty-printer. |
| crates/mergify-freeze/src/list.rs | Refactors list rendering to reuse common helpers/structs. |
| crates/mergify-freeze/src/lib.rs | Exposes new freeze subcommand modules and shared common. |
| crates/mergify-freeze/Cargo.toml | Adds iana-time-zone dependency for system timezone detection. |
| crates/mergify-core/src/http.rs | Adds Client::patch + unit test coverage. |
| crates/mergify-cli/src/main.rs | Wires freeze create/update/delete into native dispatch and adds clap parsing for new args. |
| crates/mergify-cli/Cargo.toml | Adds direct chrono dependency for clap-parsed NaiveDateTime. |
| Cargo.lock | Locks new dependencies (chrono for cli, iana-time-zone for freeze). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| //! Three responsibilities: | ||
| //! | ||
| //! - [`ScheduledFreeze`] — the wire format shared by every endpoint. | ||
| //! - [`print_freeze`] — the per-freeze human block that |
| //! open-ended emergency freeze), `matching_conditions` and | ||
| //! `exclude_conditions` only included when non-empty. On success | ||
| //! the server echoes the freeze body, which we render through the | ||
| //! shared [`print_freeze`](crate::common::print_freeze) helper. |
| let payload = UpdatePayload { | ||
| reason: opts.reason, | ||
| timezone: opts.timezone, | ||
| start: opts.start.as_ref().map(|dt| NaiveDateTimeWire(dt).iso()), | ||
| end: opts.end.as_ref().map(|dt| NaiveDateTimeWire(dt).iso()), | ||
| matching_conditions: opts.matching_conditions.map(<[String]>::to_vec), | ||
| exclude_conditions: opts.exclude_conditions.map(<[String]>::to_vec), | ||
| }; |
| /// Matching condition (repeatable). Passing the flag — even | ||
| /// with no value — replaces the existing list. |
Round-trip the three remaining freeze mutations:
freeze create—POST /v1/repos/<r>/scheduled_freezewiththe Python
CreateScheduledFreezePayloadshape:start/endalways present (null for open-ended emergency freezes),
matching_conditions/exclude_conditionskeys omitted whenthe user passed no
-c/-eflags. When--timezoneis leftoff, falls back to
iana-time-zone::get_timezone()— samerole as Python's
tzlocal.get_localzone_name().freeze update—PATCH /v1/repos/<r>/scheduled_freeze/<id>with skip-if-none on every field so PATCH semantics work
correctly: a flag the user didn't pass doesn't touch the
stored field.
freeze delete—POST /v1/repos/<r>/scheduled_freeze/<id>/deletewith
delete_reasonin the body only when supplied (the APIrequires it for active freezes; the CLI lets the server
reject a missing reason rather than pre-validating).
Adds
Client::patchon the core HTTP client, a sharedmergify-freeze::commonmodule (wire-format struct, naive-DTparser, system-timezone detection, per-freeze human printer
used by
createandupdate), andiana-time-zoneas a newdependency. The Python implementation of each command is left
in place but no longer reachable via the binary, since clap now
dispatches the whole freeze group natively.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com