diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 02febc5af..c95252d0e 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -1492,6 +1492,12 @@ impl WorkspaceCommandHelper { &self.op_summary_template_text, OperationTemplateLanguage::wrap_operation, ) + // TODO: "op_log" is not a great label name for op_summary. We could + // replace it with `operation summary` and use `operation` in + // colors.toml. TODO: It would be better to put labels like these + // consistently in the same place, e.g. `templates.toml` instead of the + // rust code. + .labeled("op_log") } pub fn short_change_id_template(&self) -> TemplateRenderer<'_, Commit> { diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index e3b373c80..97cf33b50 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -125,14 +125,12 @@ pub fn cmd_op_diff( let op_summary_template = workspace_command.operation_summary_template(); ui.request_pager(); let mut formatter = ui.stdout_formatter(); - formatter.with_label("op_log", |formatter| { - write!(formatter, "From operation ")?; - op_summary_template.format(&from_op, &mut *formatter)?; - writeln!(formatter)?; - write!(formatter, " To operation ")?; - op_summary_template.format(&to_op, &mut *formatter)?; - writeln!(formatter) - })?; + write!(formatter, "From operation ")?; + op_summary_template.format(&from_op, &mut *formatter)?; + writeln!(formatter)?; + write!(formatter, " To operation ")?; + op_summary_template.format(&to_op, &mut *formatter)?; + writeln!(formatter)?; show_op_diff( ui, diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index 556bc9609..d0e49073d 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -791,9 +791,8 @@ fn test_op_summary_diff_template() { test_env.jj_cmd_ok(&repo_path, &["new", "--no-edit", "-m=scratch"]); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo", "--color=always"]); insta::assert_snapshot!(&stdout, @""); - // BUG!! (Fixed in next commit) insta::assert_snapshot!(&stderr, @r#" - Undid operation ac20a4ff4791 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 new empty commit + Undid operation ac20a4ff4791 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 new empty commit "#); let stdout = test_env.jj_cmd_success( &repo_path, @@ -821,7 +820,7 @@ fn test_op_summary_diff_template() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo", "--color=debug"]); insta::assert_snapshot!(&stdout, @""); insta::assert_snapshot!(&stderr, @r#" - Undid operation <> <