fix(cli): accept --debug on the Rust binary and actually toggle it in Python#1464
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. 🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes --debug behavior across the split Rust/Python CLI by (1) teaching the Rust binary to accept the top-level --debug flag and forward it when dispatching to Python shims, and (2) actually enabling the Python-side debug toggle so existing is_debug() call sites start working.
Changes:
- Python: call
utils.set_debug(debug=debug)from the root Click group so--debugaffects runtime behavior. - Rust: add a global
--debugflag toCliRootand re-inject it into forwarded argv for shimmed dispatches; add unit tests covering parsing and forwarding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mergify_cli/cli.py | Propagates Click’s parsed --debug into the module-level debug toggle used by utils.is_debug(). |
| crates/mergify-cli/src/main.rs | Adds a global --debug clap flag and forwards it to Python shim argv (plus unit tests). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… Python Two coupled gaps the same user-visible bug was hiding: 1. The Rust binary never declared the top-level `--debug` flag the Python CLI accepts. Invocations like `mergify --debug ci git-refs` were rejected with `error: unexpected argument '--debug' found` the moment a command was promoted from shim to native. Add `debug: bool` as a `global = true` argument on `CliRoot`; native commands accept it as a no-op (no native code path consults the flag yet) and shimmed dispatches re-inject `--debug` at the front of the forwarded argv so the Python `cli` group still receives it. 2. The Python `cli.py` parsed `--debug` into `ctx.obj["debug"]` but never called `utils.set_debug(...)`, so the module-level `_DEBUG` toggle stayed `False` and the 6+ `if is_debug():` sites in `utils.py` / `stack/*` never fired regardless of the flag. Wire `set_debug(debug=debug)` from the root group so the flag has the effect users have always expected it to have. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Change-Id: I62ac941db12c55c988896086d7042c3dacf863af
83fc4d3 to
fe3d611
Compare
Revision history
|
Merge Queue Status
This pull request spent 11 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
…#1439) Every command crate's test module re-rolled the same ~30 LOC of `SharedBytes` / `SharedWriter` / `Captured` / `make_output` glue — about 350 LOC of pure boilerplate across 15 files, drifting over time (some `Captured` had `stderr`, some didn't; one file even carried a `_stderr_accessor_lives` dead-code stub just to silence the resulting warning). Extract the canonical version into a new `mergify-test-support` crate that other crates pull in as a `dev-dependencies`. The new `Captured` API exposes `human()` / `new(mode)` constructors and `stdout()` / `stderr()` accessors, so the common pattern shrinks from a 12-line `String::from_utf8(cap.stdout.lock().unwrap().clone())` to `let s = cap.stdout()`. Net `-418 / +114` lines across the workspace. Behavior unchanged; all 233 tests pass. The crate is `publish = false` and only ever appears under `[dev-dependencies]`, so the test-only types never leak into a production build. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Depends-On: #1464
Two coupled gaps the same user-visible bug was hiding:
The Rust binary never declared the top-level
--debugflag thePython CLI accepts. Invocations like
mergify --debug ci git-refswere rejected with
error: unexpected argument '--debug' foundthe moment a command was promoted from shim to native. Add
debug: boolas aglobal = trueargument onCliRoot; nativecommands accept it as a no-op (no native code path consults the
flag yet) and shimmed dispatches re-inject
--debugat the frontof the forwarded argv so the Python
cligroup still receives it.The Python
cli.pyparsed--debugintoctx.obj["debug"]butnever called
utils.set_debug(...), so the module-level_DEBUGtoggle stayed
Falseand the 6+if is_debug():sites inutils.py/stack/*never fired regardless of the flag. Wireset_debug(debug=debug)from the root group so the flag has theeffect users have always expected it to have.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com