From 579ba8031b3771e23b33035a693a6cde9dbceefd Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Wed, 10 Jul 2024 14:42:46 -0700 Subject: [PATCH] --color=debug: print unlabeled text without markup This makes the debug output cleaner and makes the subsequent commit easier to write. --- cli/src/formatter.rs | 2 +- cli/tests/test_global_opts.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/src/formatter.rs b/cli/src/formatter.rs index 2d8b97a54..c81bda764 100644 --- a/cli/src/formatter.rs +++ b/cli/src/formatter.rs @@ -514,7 +514,7 @@ impl Write for ColorFormatter { labels: &[String], debug: bool, ) -> io::Result<()> { - if debug { + if debug && !labels.is_empty() { write!(output, "<<{}::", labels.join(" "))?; write_sanitized(output, buf)?; write!(output, ">>")?; diff --git a/cli/tests/test_global_opts.rs b/cli/tests/test_global_opts.rs index 7db6f4ddb..8c16ea8c7 100644 --- a/cli/tests/test_global_opts.rs +++ b/cli/tests/test_global_opts.rs @@ -490,9 +490,9 @@ fn test_color_ui_messages() { // debugging colors let (stdout, _stderr) = test_env.jj_cmd_ok(&repo_path, &["st", "--color", "debug"]); insta::assert_snapshot!(stdout, @r###" - <<::The working copy is clean>> - <<::Working copy : >><><><><><><><><><><<::>> - <<::Parent commit: >><><><<:: >><><><<:: >><><<:: >><><<::>> + The working copy is clean + Working copy : <><><><><><><><><> + Parent commit: <><> <><> <> <> "###); }