diff --git a/CHANGELOG.md b/CHANGELOG.md index 72b55ccba4..30d1d187ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * New `merge-tools..diff-expected-exit-codes` config option to suppress warnings from tools exiting with non-zero exit codes. +* Add a new template alias `builtin_op_log_oneline` along with `format_operation_oneline` and `format_snapshot_operation_oneline` + ### Fixed bugs * Fixed diff selection by external tools with `jj split`/`commit -i FILESETS`. diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index ddb12d9bf8..6884a2f78c 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -151,6 +151,15 @@ label(if(current_operation, "current_operation"), ) ''' builtin_op_log_comfortable = 'builtin_op_log_compact ++ "\n"' +builtin_op_log_oneline = ''' +label(if(current_operation, "current_operation"), + coalesce( + if(snapshot, format_snapshot_operation_oneline(self)), + if(root, format_root_operation(self)), + format_operation_oneline(self), + ) +) +''' description_placeholder = 'label("description placeholder", "(no description set)")' email_placeholder = 'label("email placeholder", "(no email set)")' @@ -237,6 +246,16 @@ if(ref.tracking_present(), surround("(", ")", separate(", ", 'format_snapshot_operation(op)' = 'format_operation(op)' 'format_root_operation(root)' = 'separate(" ", root.id().short(), label("root", "root()")) ++ "\n"' + +'format_operation_oneline(op)' = ''' + separate(" ", + op.id().short(), op.user(), format_time_range(op.time()), + op.description().first_line(), + if(op.tags(), op.tags()), + ) ++ "\n" +''' +'format_snapshot_operation_oneline(op)' = 'format_operation_oneline(op)' + # We have "hidden" override "divergent", since a hidden revision does not cause # change id conflicts and is not affected by such conflicts; you have to use the # commit id to refer to a hidden revision regardless. diff --git a/cli/tests/test_evolog_command.rs b/cli/tests/test_evolog_command.rs index 0b9064033f..410374e301 100644 --- a/cli/tests/test_evolog_command.rs +++ b/cli/tests/test_evolog_command.rs @@ -326,7 +326,7 @@ fn test_evolog_with_no_template() { let repo_path = test_env.env_root().join("repo"); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["evolog", "-T"]); - insta::assert_snapshot!(stderr, @r#" + insta::assert_snapshot!(stderr, @r" error: a value is required for '--template