Skip to content

Commit

Permalink
--color=debug: print unlabeled text without markup
Browse files Browse the repository at this point in the history
This makes the debug output cleaner and makes the subsequent commit
easier to write.
  • Loading branch information
jonathantanmy committed Jul 11, 2024
1 parent 10a272a commit 579ba80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl<W: Write> Write for ColorFormatter<W> {
labels: &[String],
debug: bool,
) -> io::Result<()> {
if debug {
if debug && !labels.is_empty() {
write!(output, "<<{}::", labels.join(" "))?;
write_sanitized(output, buf)?;
write!(output, ">>")?;
Expand Down
6 changes: 3 additions & 3 deletions cli/tests/test_global_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 : >>[1m[38;5;13m<<working_copy change_id shortest prefix::m>>[38;5;8m<<working_copy change_id shortest rest::zvwutvl>>[39m<<working_copy:: >>[38;5;12m<<working_copy commit_id shortest prefix::1>>[38;5;8m<<working_copy commit_id shortest rest::67f90e7>>[39m<<working_copy:: >>[38;5;10m<<working_copy empty::(empty)>>[39m<<working_copy:: >>[38;5;10m<<working_copy empty description placeholder::(no description set)>>[0m<<::>>
<<::Parent commit: >>[1m[38;5;5m<<change_id shortest prefix::q>>[0m[38;5;8m<<change_id shortest rest::pvuntsm>>[39m<<:: >>[1m[38;5;4m<<commit_id shortest prefix::2>>[0m[38;5;8m<<commit_id shortest rest::30dd059>>[39m<<:: >>[38;5;2m<<empty::(empty)>>[39m<<:: >>[38;5;2m<<empty description placeholder::(no description set)>>[39m<<::>>
The working copy is clean
Working copy : [1m[38;5;13m<<working_copy change_id shortest prefix::m>>[38;5;8m<<working_copy change_id shortest rest::zvwutvl>>[39m<<working_copy:: >>[38;5;12m<<working_copy commit_id shortest prefix::1>>[38;5;8m<<working_copy commit_id shortest rest::67f90e7>>[39m<<working_copy:: >>[38;5;10m<<working_copy empty::(empty)>>[39m<<working_copy:: >>[38;5;10m<<working_copy empty description placeholder::(no description set)>>[0m
Parent commit: [1m[38;5;5m<<change_id shortest prefix::q>>[0m[38;5;8m<<change_id shortest rest::pvuntsm>>[39m [1m[38;5;4m<<commit_id shortest prefix::2>>[0m[38;5;8m<<commit_id shortest rest::30dd059>>[39m [38;5;2m<<empty::(empty)>>[39m [38;5;2m<<empty description placeholder::(no description set)>>[39m
"###);
}

Expand Down

0 comments on commit 579ba80

Please sign in to comment.