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
This commit is contained in:
Yuya Nishihara 2024-01-11 11:04:15 +09:00
parent bde9cda915
commit 4fed19361a
2 changed files with 12 additions and 7 deletions

View file

@ -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",

View file

@ -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)