From 1b3bcedd5344bec142df9fa90f3e2c9aff114e13 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 16 Apr 2024 16:38:38 +0900 Subject: [PATCH] cli: label log/obslog template as "log" It was removed at 522025e09187 "log: remove unused and inconsistent `log` label", but obslog had the same inconsistency. Since it's now easy to label the template output, let's re-add the "log" label. The change in test_templater_upper_lower() is noop. Formatter no longer emits reset sequence in the middle because the template is still labeled. --- cli/src/commands/log.rs | 12 +++++++----- cli/src/commands/obslog.rs | 13 +++++++------ cli/tests/test_templater.rs | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cli/src/commands/log.rs b/cli/src/commands/log.rs index cdbba0b98..db12f6959 100644 --- a/cli/src/commands/log.rs +++ b/cli/src/commands/log.rs @@ -119,11 +119,13 @@ pub(crate) fn cmd_log( Some(value) => value.to_string(), None => command.settings().config().get_string("templates.log")?, }; - template = workspace_command.parse_template( - &language, - &template_string, - CommitTemplateLanguage::wrap_commit, - )?; + template = workspace_command + .parse_template( + &language, + &template_string, + CommitTemplateLanguage::wrap_commit, + )? + .labeled("log"); node_template = workspace_command .parse_template( &language, diff --git a/cli/src/commands/obslog.rs b/cli/src/commands/obslog.rs index 69e6dd4bc..c3a5e0846 100644 --- a/cli/src/commands/obslog.rs +++ b/cli/src/commands/obslog.rs @@ -79,11 +79,13 @@ pub(crate) fn cmd_obslog( Some(value) => value.to_string(), None => command.settings().config().get_string("templates.log")?, }; - template = workspace_command.parse_template( - &language, - &template_string, - CommitTemplateLanguage::wrap_commit, - )?; + template = workspace_command + .parse_template( + &language, + &template_string, + CommitTemplateLanguage::wrap_commit, + )? + .labeled("log"); node_template = workspace_command .parse_template( &language, @@ -96,7 +98,6 @@ pub(crate) fn cmd_obslog( ui.request_pager(); let mut formatter = ui.stdout_formatter(); let formatter = formatter.as_mut(); - formatter.push_label("log")?; let mut commits = topo_order_reverse( vec![start_commit], diff --git a/cli/tests/test_templater.rs b/cli/tests/test_templater.rs index a86c40768..08e2308a3 100644 --- a/cli/tests/test_templater.rs +++ b/cli/tests/test_templater.rs @@ -124,7 +124,7 @@ fn test_templater_upper_lower() { insta::assert_snapshot!( render(r#"change_id.shortest(4).upper() ++ change_id.shortest(4).upper().lower()"#), - @"ZZZZzzzz"); + @"ZZZZzzzz"); insta::assert_snapshot!( render(r#""Hello".upper() ++ "Hello".lower()"#), @"HELLOhello"); }