From fbd6657e3ff7275eac016b6b49ae61a06d0a026c Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 3 Feb 2023 15:16:40 +0900 Subject: [PATCH] cli: omit log template separator if author.email() is empty --- src/commands/mod.rs | 2 +- tests/test_alias.rs | 2 +- tests/test_commit_template.rs | 20 ++++++++++---------- tests/test_revset_output.rs | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 5fa57b678..f0e6e917e 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1426,7 +1426,7 @@ fn log_template(settings: &UserSettings) -> String { if(divergent, label("divergent", change_id.{prefix_format} "??"), change_id.{prefix_format}) - " " author.email() + if(author.email(), " " author.email()) " " {committer_timestamp} if(branches, " " branches) if(tags, " " tags) diff --git a/tests/test_alias.rs b/tests/test_alias.rs index 54df50ef5..bf6fe1222 100644 --- a/tests/test_alias.rs +++ b/tests/test_alias.rs @@ -135,7 +135,7 @@ fn test_alias_cannot_override_builtin() { // Alias should be ignored let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root"]); insta::assert_snapshot!(stdout, @r###" - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } diff --git a/tests/test_commit_template.rs b/tests/test_commit_template.rs index 291e87c82..14582d1d4 100644 --- a/tests/test_commit_template.rs +++ b/tests/test_commit_template.rs @@ -69,7 +69,7 @@ fn test_log_default() { | (empty) description 1 o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 | add a file - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -83,7 +83,7 @@ fn test_log_default() { | (empty) description 1 o 9a[45c67d3e] test.user@example.com 2001-02-03 04:05:08.000 +07:00 4[291e264ae] | add a file - o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] + o 0[000000000] 1970-01-01 00:00:00.000 +00:00 0[000000000] (empty) (no description set) "###); @@ -102,7 +102,7 @@ fn test_log_default() { | (empty) description 1 o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 | add a file - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -116,7 +116,7 @@ fn test_log_default() { | (empty) description 1 o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 | add a file - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -127,7 +127,7 @@ fn test_log_default() { | (empty) description 1 o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 | add a file - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -138,7 +138,7 @@ fn test_log_default() { (empty) description 1 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 add a file - 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } @@ -156,7 +156,7 @@ fn test_log_default_divergence() { insta::assert_snapshot!(stdout, @r###" @ 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c | description 1 - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -172,7 +172,7 @@ fn test_log_default_divergence() { | description 2 | @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c |/ description 1 - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -183,7 +183,7 @@ fn test_log_default_divergence() { | description 2 | @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c |/ description 1 - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } @@ -203,7 +203,7 @@ fn test_log_git_head() { | initial o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:07.000 +07:00 master HEAD@git 230dd059e1b0 | (empty) (no description set) - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); } diff --git a/tests/test_revset_output.rs b/tests/test_revset_output.rs index 97f3242fb..035a60f46 100644 --- a/tests/test_revset_output.rs +++ b/tests/test_revset_output.rs @@ -161,13 +161,13 @@ fn test_alias() { let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "my-root"]); insta::assert_snapshot!(stdout, @r###" - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "identity(my-root)"]); insta::assert_snapshot!(stdout, @r###" - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); @@ -263,7 +263,7 @@ fn test_bad_alias_decl() { .assert() .success(); insta::assert_snapshot!(get_stdout_string(&assert), @r###" - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 (empty) (no description set) "###); insta::assert_snapshot!(get_stderr_string(&assert), @r###"