templates: rename "show" template alias to "builtin_log_detailed"

"jj show" is basically a "log" command with different defaults. We'll need
to consider this kind of stuff if we want to introduce namespace to templates.
This commit is contained in:
Yuya Nishihara 2023-04-22 12:28:02 +09:00
parent feeacacb7b
commit 3b49eb8064
2 changed files with 30 additions and 17 deletions

View file

@ -7,11 +7,8 @@ separate(" ",
'''
log = 'builtin_log_compact'
op_log = 'builtin_op_log_compact'
# Defined as alias to allow 'log -T show'
show = 'show'
show = 'builtin_log_detailed'
[template-aliases]
'builtin_log_oneline' = '''label(if(current_working_copy, "working_copy"),
@ -61,6 +58,18 @@ show = 'show'
)
'''
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",
"Author: " ++ author ++ " (" ++ format_timestamp(author.timestamp()) ++ ")\n",
"Committer: " ++ committer ++ " (" ++ format_timestamp(committer.timestamp()) ++ ")\n",
"\n",
indent(" ", if(description, description, description_placeholder ++ "\n")),
"\n",
)
'''
builtin_op_log_compact = '''
label(if(current_operation, "current_operation"),
@ -87,16 +96,3 @@ builtin_op_log_comfortable = 'builtin_op_log_compact ++ "\n"'
'format_time_range(time_range)' = '''
time_range.start().ago() ++ label("time", ", lasted ") ++ time_range.duration()'''
'format_timestamp(timestamp)' = 'timestamp'
# TODO: Add branches, tags, etc
'show' = '''
concat(
"Commit ID: " ++ commit_id ++ "\n",
"Change ID: " ++ change_id ++ "\n",
"Author: " ++ author ++ " (" ++ format_timestamp(author.timestamp()) ++ ")\n",
"Committer: " ++ committer ++ " (" ++ format_timestamp(committer.timestamp()) ++ ")\n",
"\n",
indent(" ", if(description, description, description_placeholder ++ "\n")),
"\n",
)
'''

View file

@ -182,6 +182,23 @@ fn test_log_builtin_templates() {
(empty) (no description set)
"###);
insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @r###"
@ Commit ID: 230dd059e1b059aefc0da06a2e5a7dbf22362f22
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
Author: Test User <test.user@example.com> (2001-02-03 04:05:07.000 +07:00)
Committer: Test User <test.user@example.com> (2001-02-03 04:05:07.000 +07:00)
(no description set)
Commit ID: 0000000000000000000000000000000000000000
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Author: <> (1970-01-01 00:00:00.000 +00:00)
Committer: <> (1970-01-01 00:00:00.000 +00:00)
(no description set)
"###);
}
#[test]