From 9e1cc460be145dfe33a5f8d23bd9559ed4adaf26 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 23 Feb 2026 01:11:39 +0900 Subject: fix(diagnose): use bail_silent for exit code and add git color.ui check Replace std::process::exit() with bail_silent() so Rust cleanup and Drop handlers run properly on non-zero exit. Add a check for git color.ui=always which is known to cause issues with git output parsing. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/diagnose.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/mozart/src/commands/diagnose.rs b/crates/mozart/src/commands/diagnose.rs index dc1ea85..0c027d7 100644 --- a/crates/mozart/src/commands/diagnose.rs +++ b/crates/mozart/src/commands/diagnose.rs @@ -251,6 +251,21 @@ fn check_git() -> CheckResult { return CheckResult::Warning("git --version returned a non-zero exit code".to_string()); } + // Check color.ui setting before parsing the version + if let Ok(color_output) = std::process::Command::new("git") + .args(["config", "color.ui"]) + .output() + { + let color_val = String::from_utf8_lossy(&color_output.stdout); + if color_val.trim().eq_ignore_ascii_case("always") { + return CheckResult::Warning( + "Your git color.ui setting is set to always, this is known to create issues. \ + Use \"git config --global color.ui true\" to set it correctly." + .to_string(), + ); + } + } + let stdout = String::from_utf8_lossy(&output.stdout); let version_str = stdout.trim(); @@ -470,7 +485,7 @@ pub async fn execute( } if exit_code != 0 { - std::process::exit(exit_code); + return Err(mozart_core::exit_code::bail_silent(exit_code)); } Ok(()) } -- cgit v1.3.1