Skip to content

refactor(rust): dedupe emit-helper boilerplate across command crates#1438

Merged
mergify[bot] merged 2 commits into
mainfrom
devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9
May 26, 2026
Merged

refactor(rust): dedupe emit-helper boilerplate across command crates#1438
mergify[bot] merged 2 commits into
mainfrom
devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 19, 2026

A grab-bag of small DRY wins surfaced by the post-port review:

  • Add Output::emit_json_value(&serde_json::Value) to
    mergify-core. The --json passthrough commands (queue status,
    queue show, freeze list) all carried byte-identical
    emit_json private helpers that pretty-printed a value to either
    the JSON or the human sink. Centralize once.
  • Drop the enabled_fg wrapper in queue show: its body was
    exactly what Theme::fg already does, so call theme.fg(...)
    directly. Saves a helper + 13 call-site rewrites of the same
    redundant indirection.
  • Drop spurious response.field.clone() calls in queue pause,
    config validate, and config simulate. The closures handed to
    Output::emit borrow from the outer &Response parameter; the
    trait method doesn't require 'static, so the clones were
    defensive noise.

No behavior change. All workspace tests still pass.

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

Depends-On: #1437

@jd
Copy link
Copy Markdown
Member Author

jd commented May 19, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(rust): port freeze create/update/delete to native Rust #1437
2 refactor(rust): dedupe emit-helper boilerplate across command crates #1438 👈
3 refactor(rust): share test scaffolding via mergify-test-support crate #1439
4 refactor(core): introduce CommandContext for the queue+freeze prelude #1441
5 refactor(ci): consolidate the CI-env scrubber into a shared testing module #1442
6 refactor: drop stale Phase X.Y doc markers and one inline color branch #1443
7 refactor(tui): share StyledGlyph across queue show/status renderers #1444
8 refactor(queue): drop indexmap, group_by_scope returns a Vec<(K, V)> #1445
9 refactor(ci): swap uuid for getrandom in the GHA heredoc delimiter #1446
10 refactor(config): standardize the workspace on serde_yaml_ng for YAML parsing #1447
11 test(ci): add live smoke test for ci scopes select-all path #1460
12 feat(rust): port ci scopes to native Rust #1461

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 19, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 ⛓️ Depends-On Requirements

Wonderful, this rule succeeded.

Requirement based on the presence of Depends-On in the body of the pull request

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@jd jd marked this pull request as ready for review May 19, 2026 12:48
@jd jd force-pushed the devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9 branch from 721eacd to a6bf822 Compare May 19, 2026 13:04
@jd jd temporarily deployed to func-tests-live May 19, 2026 13:04 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 19, 2026 13:04 — with GitHub Actions Inactive
@jd
Copy link
Copy Markdown
Member Author

jd commented May 19, 2026

Revision history

# Type Changes Reason Date
1 initial 721eacd 2026-05-19 13:04 UTC
2 content 721eacd → a6bf822 (raw) 2026-05-19 13:04 UTC
3 rebase a6bf822 → ac72c27 (rebase only) 2026-05-19 14:15 UTC
4 rebase ac72c27 → 7196c62 (rebase only) 2026-05-20 08:42 UTC
5 rebase 7196c62 → 7e4d039 (rebase only) 2026-05-20 09:05 UTC
6 rebase 7e4d039 → 945d1df (rebase only) 2026-05-21 07:25 UTC
7 rebase 945d1df → ca82ffb (rebase only) 2026-05-21 07:56 UTC
8 rebase ca82ffb → 26efd50 (rebase only) 2026-05-21 12:39 UTC
9 rebase 26efd50 → 00020fd (rebase only) 2026-05-22 07:10 UTC
10 rebase 00020fd → 02003f4 (rebase only) 2026-05-22 14:40 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 19, 2026 13:04 Failure
@mergify mergify Bot requested a review from a team May 19, 2026 13:17
@jd jd force-pushed the devs/jd/worktree-rust-port/port-freeze-create-update-delete-native-rust--653dbf47 branch from 50fcb0d to f322a06 Compare May 19, 2026 14:14
@jd jd force-pushed the devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9 branch from a6bf822 to ac72c27 Compare May 19, 2026 14:14
@jd jd temporarily deployed to func-tests-live May 19, 2026 14:15 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 19, 2026 14:15 Failure
@jd jd temporarily deployed to func-tests-live May 22, 2026 07:10 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 22, 2026 07:10 Failure
jd and others added 2 commits May 22, 2026 16:40
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
A grab-bag of small DRY wins surfaced by the post-port review:

- Add `Output::emit_json_value(&serde_json::Value)` to
  `mergify-core`. The `--json` passthrough commands (`queue status`,
  `queue show`, `freeze list`) all carried byte-identical
  `emit_json` private helpers that pretty-printed a value to either
  the JSON or the human sink. Centralize once.
- Drop the `enabled_fg` wrapper in `queue show`: its body was
  exactly what `Theme::fg` already does, so call `theme.fg(...)`
  directly. Saves a helper + 13 call-site rewrites of the same
  redundant indirection.
- Drop spurious `response.field.clone()` calls in `queue pause`,
  `config validate`, and `config simulate`. The closures handed to
  `Output::emit` borrow from the outer `&Response` parameter; the
  trait method doesn't require `'static`, so the clones were
  defensive noise.

No behavior change. All workspace tests still pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: Ied32eef956ebd71a03005530cc394612afd46e5d
@jd jd force-pushed the devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9 branch from 00020fd to 02003f4 Compare May 22, 2026 14:40
@jd jd temporarily deployed to func-tests-live May 22, 2026 14:40 — with GitHub Actions Inactive
@mergify mergify Bot deployed to Mergify Merge Protections May 22, 2026 14:40 Active
Base automatically changed from devs/jd/worktree-rust-port/port-freeze-create-update-delete-native-rust--653dbf47 to main May 26, 2026 07:19
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 26, 2026

Merge Queue Status

This pull request spent 3 hours 18 minutes 5 seconds in the queue, including 3 hours 17 minutes 47 seconds running CI.

Waiting for
  • check-success=ci-gate
All conditions

Reason

New commits have been added to the draft pull request that were not made by Mergify

Hint

If you want to requeue this pull request, you can post a @mergifyio queue comment.

mergify Bot added a commit that referenced this pull request May 26, 2026
@jd
Copy link
Copy Markdown
Member Author

jd commented May 26, 2026

@Mergifyio queue

@jd
Copy link
Copy Markdown
Member Author

jd commented May 26, 2026

@Mergifyio queue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 26, 2026

Merge Queue Status

This pull request spent 15 minutes 51 seconds in the queue, including 15 minutes 5 seconds running CI.

Required conditions to merge

@mergify mergify Bot added queued and removed dequeued labels May 26, 2026
mergify Bot added a commit that referenced this pull request May 26, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 26, 2026

queue

☑️ Command queue ignored because it is already running from a previous command.

@mergify mergify Bot merged commit a8f4ab2 into main May 26, 2026
19 checks passed
@mergify mergify Bot deleted the devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9 branch May 26, 2026 15:51
@mergify mergify Bot removed the queued label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants