ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: hide irrelevant information about root commit in default log templates

I've extracted the `builtin_log_root` template for users to customize the
default templates without fully overriding them, for example I would remove
the change_id/commit_id for myself - and we discussed in Discord that leaving
those makes sense for the user to be reminded/teached that the root commit has
a change id made from z's.
This commit is contained in:
Anton Bulakh 2023-08-15 16:18:56 +03:00 committed by Anton Bulakh
parent 82923afcc5
commit dc6e1d7dee
9 changed files with 83 additions and 82 deletions

View file

@ -31,6 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### New features
* Default template for `jj log` now does not show irrelevant information
(timestamp, empty, message placeholder etc.) about the root commit.
* Commit templates now support the `root` keyword, which is `true` for the root
commit and `false` for every other commit.

View file

@ -33,6 +33,7 @@
"conflict" = "red"
"empty" = "green"
"separator" = "bright black"
"root" = {fg = "bright green", bold = true}
"working_copy" = { bold = true }
"working_copy commit_id" = "bright blue"

View file

@ -29,7 +29,10 @@ op_log = 'builtin_op_log_compact'
show = 'builtin_log_detailed'
[template-aliases]
'builtin_log_oneline' = '''label(if(current_working_copy, "working_copy"),
'builtin_log_oneline' = '''
if(root,
builtin_log_root(change_id, commit_id),
label(if(current_working_copy, "working_copy"),
concat(
separate(" ",
label(
@ -50,8 +53,12 @@ show = 'builtin_log_detailed'
) ++ "\n",
),
)
)
'''
'builtin_log_compact' = '''label(if(current_working_copy, "working_copy"),
'builtin_log_compact' = '''
if(root,
builtin_log_root(change_id, commit_id),
label(if(current_working_copy, "working_copy"),
concat(
separate(" ",
label(
@ -74,6 +81,7 @@ show = 'builtin_log_detailed'
) ++ "\n",
),
)
)
'''
builtin_log_comfortable = 'builtin_log_compact ++ "\n"'
# TODO: Add branches, tags, etc
@ -104,6 +112,15 @@ label(if(current_operation, "current_operation"),
'''
builtin_op_log_comfortable = 'builtin_op_log_compact ++ "\n"'
'builtin_log_root(change_id, commit_id)' = '''
separate(" ",
format_short_change_id(change_id),
label("root", "root"),
format_short_commit_id(commit_id),
branches
)
'''
'description_placeholder' = 'label("description", "(no description set)")'
'commit_summary_separator' = 'label("separator", " | ")'

View file

@ -137,8 +137,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###"
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
}

View file

@ -128,8 +128,7 @@ fn test_log_default() {
(empty) description 1
qpvuntsm test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264
add a file
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
// Color
@ -139,8 +138,7 @@ fn test_log_default() {
(empty) description 1
qpvuntsm test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264
add a file
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
// Color without graph
@ -150,8 +148,7 @@ fn test_log_default() {
(empty) description 1
qpvuntsm test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264
add a file
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
}
@ -164,23 +161,20 @@ fn test_log_builtin_templates() {
insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r###"
@ qpvuntsm test.user 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set)
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000 (empty) (no description set)
zzzzzzzz root 00000000
"###);
insta::assert_snapshot!(render(r#"builtin_log_compact"#), @r###"
@ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059
(empty) (no description set)
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @r###"
@ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059
(empty) (no description set)
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @r###"
@ -214,8 +208,7 @@ fn test_log_obslog_divergence() {
insta::assert_snapshot!(stdout, @r###"
@ qpvuntsm test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e
description 1
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
// Create divergence
@ -230,8 +223,7 @@ fn test_log_obslog_divergence() {
description 2
@ qpvuntsm?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e
description 1
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
// Color
@ -241,8 +233,7 @@ fn test_log_obslog_divergence() {
description 2
@ qpvuntsm?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e
description 1
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
// Obslog and hidden divergent
@ -283,8 +274,7 @@ fn test_log_git_head() {
initial
qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 master HEAD@git 230dd059
(empty) (no description set)
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
}
@ -309,8 +299,7 @@ fn test_log_customize_short_id() {
insta::assert_snapshot!(stdout, @r###"
@ Q_pvun test.user@example.com 2001-02-03 04:05:08.000 +07:00 6_9542
(empty) first
Z_zzzz 1970-01-01 00:00:00.000 +00:00 0_0000
(empty) (no description set)
Z_zzzz root 0_0000
"###);
// Customize only the change id
@ -328,7 +317,6 @@ fn test_log_customize_short_id() {
insta::assert_snapshot!(stdout, @r###"
@ QPVUNTSM test.user@example.com 2001-02-03 04:05:08.000 +07:00 69542c19
(empty) first
ZZZZZZZZ 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
ZZZZZZZZ root 00000000
"###);
}

View file

@ -649,8 +649,7 @@ fn test_diff_external_tool() {
--
file1
file2
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
--
"###);

View file

@ -321,8 +321,7 @@ fn test_init_git_external_but_git_dir_exists() {
// The local ".git" repository is unrelated, so no commits should be imported
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-r", "@-"]);
insta::assert_snapshot!(stdout, @r###"
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
// Check that Git HEAD is not set because this isn't a colocated repo

View file

@ -49,8 +49,7 @@ fn test_log_legacy_range_operator() {
insta::assert_snapshot!(stdout, @r###"
@ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059
(empty) (no description set)
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
insta::assert_snapshot!(stderr, @r###"
The `:` revset operator is deprecated. Please switch to `::`.
@ -59,8 +58,7 @@ fn test_log_legacy_range_operator() {
insta::assert_snapshot!(stdout, @r###"
@ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059
(empty) (no description set)
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
insta::assert_snapshot!(stderr, @r###"
The `:` revset operator is deprecated. Please switch to `::`.

View file

@ -256,14 +256,12 @@ fn test_alias() {
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "my-root"]);
insta::assert_snapshot!(stdout, @r###"
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "identity(my-root)"]);
insta::assert_snapshot!(stdout, @r###"
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", "root & syntax-error"]);
@ -385,8 +383,7 @@ fn test_bad_alias_decl() {
// Invalid declaration should be warned and ignored.
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["log", "-r", "my-root"]);
insta::assert_snapshot!(stdout, @r###"
zzzzzzzz 1970-01-01 00:00:00.000 +00:00 00000000
(empty) (no description set)
zzzzzzzz root 00000000
"###);
insta::assert_snapshot!(stderr, @r###"
Failed to load "revset-aliases."bad"": --> 1:1