From 30e29f7b263516b61e2ee9244e5609a21bfc5aa4 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 19 May 2026 14:57:36 +0200 Subject: [PATCH] refactor: drop stale Phase X.Y doc markers and one inline color branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two unrelated polish items grouped because each is too small for its own commit: 1. Module docs across `mergify-core`, `mergify-config`, `mergify-queue`, `mergify-cli`, and `mergify-py-shim` were pinned to the phase numbering the port plan used during bootstrapping ("Phase 1.2 populates…", "Phase 1.7 ports…", "Phase 6 deletes…"). Those references no longer aid the reader and contradict the project rule about not embedding phase numbers in long-lived artifacts — rewrite each docstring to describe the module's *current* shape and let `git log` reconstruct the trajectory if anyone needs it. 2. `freeze/list.rs::write_row` still had an `if theme.enabled { … theme.fg(c) } else { Style::new() }` branch around the Status cell — the same redundant indirection the earlier dedup pass removed elsewhere. `Theme::fg` already collapses to `Style::new()` when colors are disabled, so the outer branch is pure noise. Drop it. Co-Authored-By: Claude Opus 4.7 Change-Id: I477e098578452de9e955119241ce7b92c0641b22 --- crates/mergify-cli/src/main.rs | 20 ++++++++++---------- crates/mergify-config/src/lib.rs | 4 ++-- crates/mergify-core/src/error.rs | 7 +++---- crates/mergify-core/src/exit_code.rs | 6 +++--- crates/mergify-core/src/lib.rs | 10 +++++----- crates/mergify-core/src/output.rs | 2 +- crates/mergify-freeze/src/list.rs | 12 ++++-------- crates/mergify-py-shim/src/lib.rs | 3 ++- crates/mergify-queue/src/lib.rs | 11 +++-------- 9 files changed, 33 insertions(+), 42 deletions(-) diff --git a/crates/mergify-cli/src/main.rs b/crates/mergify-cli/src/main.rs index db4d73ff..1a289cb7 100644 --- a/crates/mergify-cli/src/main.rs +++ b/crates/mergify-cli/src/main.rs @@ -1,17 +1,17 @@ //! `mergify` binary entry point. //! //! Dispatch logic: every invocation is speculatively parsed with -//! clap, which knows about the native commands -//! ([`ConfigSubcommand::Validate`], [`ConfigSubcommand::Simulate`]). -//! If clap succeeds with a known native variant the binary runs -//! that code path natively. Any parse failure — including -//! subcommands clap doesn't know about (``stack push``, ``ci -//! junit-process``, …) — falls through to [`mergify_py_shim::run`], -//! which hands the original argv to ``python3 -m mergify_cli``. +//! clap, which knows about the natively-ported commands listed in +//! [`NATIVE_COMMANDS`]. If clap succeeds with a known native +//! variant the binary runs that code path natively. Any parse +//! failure — including subcommands clap doesn't know about +//! (``stack push``, ``ci junit-process``, …) — falls through to +//! [`mergify_py_shim::run`], which hands the original argv to +//! ``python3 -m mergify_cli``. //! -//! As each command ports (Phase 1.4+), new variants land on the -//! clap enum and the shim fallback shrinks. Phase 6 deletes the -//! shim entirely. +//! As each Python command is ported to Rust, a new entry lands in +//! [`NATIVE_COMMANDS`] and a matching clap variant; the shim +//! fallback shrinks accordingly until it can be removed entirely. use std::env; use std::path::PathBuf; diff --git a/crates/mergify-config/src/lib.rs b/crates/mergify-config/src/lib.rs index 8526c3b7..c9593158 100644 --- a/crates/mergify-config/src/lib.rs +++ b/crates/mergify-config/src/lib.rs @@ -1,7 +1,7 @@ //! Native Rust implementation of the `mergify config` subcommands. //! -//! Phase 1.3 ports `config validate`. Phase 1.3b adds `config -//! simulate`. Both share the config-file resolver in [`paths`]. +//! Hosts `config validate` and `config simulate`; both share the +//! config-file resolver in [`paths`]. pub mod paths; pub mod simulate; diff --git a/crates/mergify-core/src/error.rs b/crates/mergify-core/src/error.rs index 97c6a478..59573e47 100644 --- a/crates/mergify-core/src/error.rs +++ b/crates/mergify-core/src/error.rs @@ -5,10 +5,9 @@ //! the appropriate `ExitCode` and writes a human-readable message //! to stderr before exiting. //! -//! This enum grows as new error sources are added. Today it covers -//! the categories needed to port the `config` pilot (Phase 1.3); -//! subsequent sub-phases add variants for HTTP failures, git -//! subprocess failures, and so on. +//! This enum grows as new error sources are added — add a variant +//! per error category, never a generic `String` catch-all for new +//! kinds of failure that have their own exit code. use std::io; diff --git a/crates/mergify-core/src/exit_code.rs b/crates/mergify-core/src/exit_code.rs index b1f10118..dd703bdd 100644 --- a/crates/mergify-core/src/exit_code.rs +++ b/crates/mergify-core/src/exit_code.rs @@ -2,9 +2,9 @@ //! //! Mirrors `mergify_cli.exit_codes.ExitCode` in the Python //! implementation. The contract — which (command, failure mode) -//! maps to which exit code — is locked by Phase 0.1 and enforced by -//! the compat-test harness. Changing a variant's numeric value is a -//! breaking change for downstream scripts. +//! maps to which exit code — is enforced by the compat-test +//! harness. Changing a variant's numeric value is a breaking change +//! for downstream scripts. use std::process::ExitCode as ProcessExitCode; diff --git a/crates/mergify-core/src/lib.rs b/crates/mergify-core/src/lib.rs index d362f1d9..064eebde 100644 --- a/crates/mergify-core/src/lib.rs +++ b/crates/mergify-core/src/lib.rs @@ -1,7 +1,5 @@ //! Shared foundations for the mergify CLI Rust port. //! -//! Phase 1.2 populates this crate with: -//! //! - [`exit_code::ExitCode`] — typed exit codes mirroring the //! Python `exit_codes.py` contract. //! - [`error::CliError`] — top-level error enum with deterministic @@ -11,9 +9,11 @@ //! in. //! - [`http::Client`] — wraps `reqwest` with bearer auth, retry, //! and typed error mapping for the Mergify and GitHub APIs. -//! -//! Git operations, interactive prompts, and config loading arrive -//! in subsequent sub-phases. +//! - [`auth`] — resolve `--repository` / `--token` / `--api-url` +//! from the same flag → env → fallback chain the Python CLI uses. +//! - [`command_context::CommandContext`] — bundle the resolved +//! trio + a pre-configured Mergify HTTP client for the +//! queue/freeze command preludes. pub mod auth; pub mod command_context; diff --git a/crates/mergify-core/src/output.rs b/crates/mergify-core/src/output.rs index a8892566..44a18413 100644 --- a/crates/mergify-core/src/output.rs +++ b/crates/mergify-core/src/output.rs @@ -5,7 +5,7 @@ //! directly. This keeps the JSON and human rendering paths //! symmetric, lets commands stay test-friendly, and gives a single //! place to enforce the "stdout must be a single JSON document -//! under `--json`" invariant (Phase 0.3). +//! under `--json`" invariant. //! //! The trait is deliberately small. Commands emit one "result" //! value that knows how to render itself both as JSON (via diff --git a/crates/mergify-freeze/src/list.rs b/crates/mergify-freeze/src/list.rs index c06d32d0..883917c0 100644 --- a/crates/mergify-freeze/src/list.rs +++ b/crates/mergify-freeze/src/list.rs @@ -188,16 +188,12 @@ fn write_row( spaces = " ".repeat(pad), )?; } else if HEADERS[i] == "Status" { + // `Theme::fg` already collapses to `Style::new()` when + // colors are disabled — no need for an extra branch. let style = if cell == "active" { - if theme.enabled { - theme.fg(AnsiColor::Green) - } else { - anstyle::Style::new() - } - } else if theme.enabled { - theme.fg(AnsiColor::Yellow) + theme.fg(AnsiColor::Green) } else { - anstyle::Style::new() + theme.fg(AnsiColor::Yellow) }; write!( w, diff --git a/crates/mergify-py-shim/src/lib.rs b/crates/mergify-py-shim/src/lib.rs index 47b25201..04acdc80 100644 --- a/crates/mergify-py-shim/src/lib.rs +++ b/crates/mergify-py-shim/src/lib.rs @@ -21,7 +21,8 @@ //! native impl first and only falls back to [`run`] for un-ported //! commands. The plan is for each port PR to delete its Python //! implementation in the same change, so the shim's reach shrinks -//! one command at a time. Phase 6 deletes this crate entirely. +//! one command at a time; this crate is deleted entirely once +//! everything is ported. use std::env; use std::io; diff --git a/crates/mergify-queue/src/lib.rs b/crates/mergify-queue/src/lib.rs index fa9f8b56..58fdd504 100644 --- a/crates/mergify-queue/src/lib.rs +++ b/crates/mergify-queue/src/lib.rs @@ -1,13 +1,8 @@ //! Native Rust implementation of the `mergify queue` subcommands. //! -//! Phase 1.5 ported `pause` and `unpause` — two idempotent API -//! calls that rest on the HTTP client added in 1.2b and the -//! `put`/`delete_if_exists` methods added alongside this crate. -//! Phase 1.7 ports `status`, the read-only command that fetches -//! the merge-queue snapshot and renders it either as a JSON -//! passthrough or as the human-friendly batch tree + waiting list. -//! `queue show` stays shimmed until its conditions/checks tree -//! ports next. +//! Hosts `pause` / `unpause` (idempotent API mutations), `status` +//! (read-only batch tree + waiting list, with JSON passthrough), +//! and `show` (per-PR detail with checks + conditions tree). pub mod pause; pub mod show;