diff --git a/CHANGELOG.md b/CHANGELOG.md index 263390d10c..e432f64bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### New features +* `jj tag list` now prints commit summary along with the tag name. + ### Fixed bugs ## [0.17.0] - 2024-05-01 diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 416863639c..1b7e071758 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -18,7 +18,7 @@ op_log = 'builtin_op_log_compact' show = 'builtin_log_detailed' tag_list = ''' -label("tag", name) ++ "\n" +label("tag", name) ++ format_ref_targets(self) ++ "\n" ''' [template-aliases] @@ -147,6 +147,17 @@ separate(" ", ) ++ "\n" ''' +'format_ref_targets(ref)' = ''' +if(ref.conflict(), + separate("\n", + " " ++ label("conflict", "(conflicted)") ++ ":", + ref.removed_targets().map(|c| " - " ++ format_commit_summary_with_refs(c, "")).join("\n"), + ref.added_targets().map(|c| " + " ++ format_commit_summary_with_refs(c, "")).join("\n"), + ), + ": " ++ format_commit_summary_with_refs(ref.normal_target(), ""), +) +''' + 'format_operation(op)' = ''' concat( separate(" ", op.id().short(), op.user(), format_time_range(op.time())), "\n", diff --git a/cli/tests/test_tag_command.rs b/cli/tests/test_tag_command.rs index 237b36d880..491c41c6ec 100644 --- a/cli/tests/test_tag_command.rs +++ b/cli/tests/test_tag_command.rs @@ -52,30 +52,36 @@ fn test_tag_list() { insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["tag", "list"]), @r###" - conflicted_tag - test_tag - test_tag2 + conflicted_tag (conflicted): + - rlvkpnrz caf975d0 (empty) commit1 + + zsuskuln 3db783e0 (empty) commit2 + + royxmykx 68d950ce (empty) commit3 + test_tag: rlvkpnrz caf975d0 (empty) commit1 + test_tag2: zsuskuln 3db783e0 (empty) commit2 "###); insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["tag", "list", "--color=always"]), @r###" - conflicted_tag - test_tag - test_tag2 + conflicted_tag (conflicted): + - rlvkpnrz caf975d0 (empty) commit1 + + zsuskuln 3db783e0 (empty) commit2 + + royxmykx 68d950ce (empty) commit3 + test_tag: rlvkpnrz caf975d0 (empty) commit1 + test_tag2: zsuskuln 3db783e0 (empty) commit2 "###); // Test pattern matching. insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["tag", "list", "test_tag2"]), @r###" - test_tag2 + test_tag2: zsuskuln 3db783e0 (empty) commit2 "###); insta::assert_snapshot!( test_env.jj_cmd_success(&repo_path, &["tag", "list", "glob:test_tag?"]), @r###" - test_tag2 + test_tag2: zsuskuln 3db783e0 (empty) commit2 "###); let template = r#"