From 4fed19361ace71d192c7c8a301c241c0a46f8eb8 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 11 Jan 2024 11:04:15 +0900 Subject: [PATCH] cli: include branches and tags in default "show" template The formatting is closer to hg than git just because it's easier to conditionalize the whole line per keyword. Our template language doesn't have infix logical operators. Unlike the other default templates, all remote branches are displayed because it's "detailed" output. Closes #2509 --- cli/src/config/templates.toml | 3 ++- cli/tests/test_commit_template.rs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 3d2b99294..459ae11f1 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -76,11 +76,12 @@ if(root, ) ''' builtin_log_comfortable = 'builtin_log_compact ++ "\n"' -# TODO: Add branches, tags, etc 'builtin_log_detailed' = ''' concat( "Commit ID: " ++ commit_id ++ "\n", "Change ID: " ++ change_id ++ "\n", + if(branches, "Branches: " ++ separate(" ", local_branches, remote_branches) ++ "\n"), + if(tags, "Tags: " ++ tags ++ "\n"), "Author: " ++ format_detailed_signature(author) ++ "\n", "Committer: " ++ format_detailed_signature(committer) ++ "\n", "\n", diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index c1d092869..6bb6a74be 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -180,15 +180,16 @@ fn test_log_builtin_templates() { "new", ], ); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "my-branch"]); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r###" - @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 (empty) (no description set) + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 (empty) (no description set) ◉ qpvuntsm test.user 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set) ◉ zzzzzzzz root() 00000000 "###); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @r###" - @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 │ (empty) (no description set) ◉ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 │ (empty) (no description set) @@ -196,7 +197,7 @@ fn test_log_builtin_templates() { "###); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @r###" - @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 │ (empty) (no description set) │ ◉ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 @@ -208,6 +209,7 @@ fn test_log_builtin_templates() { insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @r###" @ Commit ID: dc31539712c7294d1d712cec63cef4504b94ca74 │ Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp + │ Branches: my-branch │ Author: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00) │ Committer: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00) │ @@ -246,15 +248,16 @@ fn test_log_builtin_templates_colored() { "new", ], ); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "my-branch"]); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r###" - @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 (empty) (no description set) + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 (empty) (no description set) ◉ qpvuntsm test.user 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set) ◉ zzzzzzzz root() 00000000 "###); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @r###" - @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 │ (empty) (no description set) ◉ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 │ (empty) (no description set) @@ -262,7 +265,7 @@ fn test_log_builtin_templates_colored() { "###); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @r###" - @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 │ (empty) (no description set) │ ◉ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 @@ -274,6 +277,7 @@ fn test_log_builtin_templates_colored() { insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @r###" @ Commit ID: dc31539712c7294d1d712cec63cef4504b94ca74 │ Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp + │ Branches: my-branch │ Author: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00) │ Committer: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00) │