From a9ca855197ca77a257f974c267644feb4a8d7021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20=C3=84lgmyr?= Date: Sat, 13 Apr 2024 21:12:16 +0200 Subject: [PATCH 1/2] Add template aliases with node symbol configs. --- cli/src/config/colors.toml | 8 ++++ cli/src/config/templates.toml | 63 ++++++++++++++++++++++++++++++++ cli/tests/test_log_command.rs | 4 ++ cli/tests/test_obslog_command.rs | 4 ++ cli/tests/test_operations.rs | 4 ++ cli/tests/test_show_command.rs | 4 ++ cli/tests/test_templater.rs | 2 +- 7 files changed, 88 insertions(+), 1 deletion(-) diff --git a/cli/src/config/colors.toml b/cli/src/config/colors.toml index 79c748a4b8..dde26f15ae 100644 --- a/cli/src/config/colors.toml +++ b/cli/src/config/colors.toml @@ -87,3 +87,11 @@ "op_log current_operation id" = "bright blue" "op_log current_operation user" = "yellow" # No bright yellow, see comment above "op_log current_operation time" = "bright cyan" + +"node" = { bold = true } +"node elided" = { fg = "bright black" } +"node working_copy" = { fg = "green" } +"node current_operation" = { fg = "green" } +"node immutable" = { fg = "bright cyan" } +"node conflict" = { fg = "red" } +"node normal" = { bold = false } diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 4a82ae15b3..332b973393 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -165,3 +165,66 @@ if(hidden, ) ) ''' + +'label_log_node(content)' = ''' +label("node", + coalesce( + if(!self, label("elided", content)), + if(immutable, label("immutable", content)), + if(conflict, label("conflict", content)), + if(current_working_copy, label("working_copy", content)), + label("normal", content), + ) +) +''' + +'label_op_log_node(content)' = ''' +label("node", + coalesce( + if(current_operation, label("current_operation", content)), + label("normal", content), + ) +) +''' + +builtin_log_node = ''' +label_log_node( + coalesce( + if(!self, "~"), + if(current_working_copy, "@"), + if(immutable, "◆"), + if(conflict, "×"), + "○", + ) +) +''' + +builtin_log_node_ascii = ''' +label_log_node( + coalesce( + if(!self, "~"), + if(current_working_copy, "@"), + if(immutable, "#"), + if(conflict, "x"), + "o", + ) +) +''' + +builtin_op_log_node = ''' +label_op_log_node( + coalesce( + if(current_operation, "@"), + "○", + ) +) +''' + +builtin_op_log_node_ascii = ''' +label_op_log_node( + coalesce( + if(current_operation, "@"), + "o", + ) +) +''' diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index 9b6ec1bd42..dbccba748b 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -44,9 +44,13 @@ fn test_log_with_no_template() { - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed + - builtin_log_node + - builtin_log_node_ascii - builtin_log_oneline - builtin_op_log_comfortable - builtin_op_log_compact + - builtin_op_log_node + - builtin_op_log_node_ascii - commit_summary_separator - description_placeholder - email_placeholder diff --git a/cli/tests/test_obslog_command.rs b/cli/tests/test_obslog_command.rs index 2d0cb29b33..6f682cf129 100644 --- a/cli/tests/test_obslog_command.rs +++ b/cli/tests/test_obslog_command.rs @@ -279,9 +279,13 @@ fn test_obslog_with_no_template() { - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed + - builtin_log_node + - builtin_log_node_ascii - builtin_log_oneline - builtin_op_log_comfortable - builtin_op_log_compact + - builtin_op_log_node + - builtin_op_log_node_ascii - commit_summary_separator - description_placeholder - email_placeholder diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index 4e05eb55af..e0b54b9384 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -140,9 +140,13 @@ fn test_op_log_with_no_template() { - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed + - builtin_log_node + - builtin_log_node_ascii - builtin_log_oneline - builtin_op_log_comfortable - builtin_op_log_compact + - builtin_op_log_node + - builtin_op_log_node_ascii - commit_summary_separator - description_placeholder - email_placeholder diff --git a/cli/tests/test_show_command.rs b/cli/tests/test_show_command.rs index f26c1c6909..15cf1cffc1 100644 --- a/cli/tests/test_show_command.rs +++ b/cli/tests/test_show_command.rs @@ -64,9 +64,13 @@ fn test_show_with_no_template() { - builtin_log_comfortable - builtin_log_compact - builtin_log_detailed + - builtin_log_node + - builtin_log_node_ascii - builtin_log_oneline - builtin_op_log_comfortable - builtin_op_log_compact + - builtin_op_log_node + - builtin_op_log_node_ascii - commit_summary_separator - description_placeholder - email_placeholder diff --git a/cli/tests/test_templater.rs b/cli/tests/test_templater.rs index cc076c9fe5..a86c407683 100644 --- a/cli/tests/test_templater.rs +++ b/cli/tests/test_templater.rs @@ -111,7 +111,7 @@ fn test_templater_parse_error() { | ^-----^ | = Keyword "builtin" doesn't exist - Hint: Did you mean "builtin_change_id_with_hidden_and_divergent_info", "builtin_log_comfortable", "builtin_log_compact", "builtin_log_detailed", "builtin_log_oneline", "builtin_op_log_comfortable", "builtin_op_log_compact"? + Hint: Did you mean "builtin_change_id_with_hidden_and_divergent_info", "builtin_log_comfortable", "builtin_log_compact", "builtin_log_detailed", "builtin_log_node", "builtin_log_node_ascii", "builtin_log_oneline", "builtin_op_log_comfortable", "builtin_op_log_compact", "builtin_op_log_node", "builtin_op_log_node_ascii"? "###); } From 91880182fa94547faabe03873db286103244c82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20=C3=84lgmyr?= Date: Sun, 14 Apr 2024 23:20:26 +0200 Subject: [PATCH 2/2] Move to inline labeling and building a single label in log node template. --- cli/src/config/colors.toml | 10 ++--- cli/src/config/templates.toml | 73 +++++++++++++++++------------------ 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/cli/src/config/colors.toml b/cli/src/config/colors.toml index dde26f15ae..635a66f6db 100644 --- a/cli/src/config/colors.toml +++ b/cli/src/config/colors.toml @@ -88,10 +88,8 @@ "op_log current_operation user" = "yellow" # No bright yellow, see comment above "op_log current_operation time" = "bright cyan" -"node" = { bold = true } "node elided" = { fg = "bright black" } -"node working_copy" = { fg = "green" } -"node current_operation" = { fg = "green" } -"node immutable" = { fg = "bright cyan" } -"node conflict" = { fg = "red" } -"node normal" = { bold = false } +"node working_copy" = { fg = "green", bold = true } +"node current_operation" = { fg = "green", bold = true } +"node immutable" = { fg = "bright cyan", bold = true } +"node conflict" = { fg = "red", bold = true } diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 332b973393..2cfa854fac 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -166,64 +166,63 @@ if(hidden, ) ''' -'label_log_node(content)' = ''' -label("node", - coalesce( - if(!self, label("elided", content)), - if(immutable, label("immutable", content)), - if(conflict, label("conflict", content)), - if(current_working_copy, label("working_copy", content)), - label("normal", content), - ) -) -''' - -'label_op_log_node(content)' = ''' -label("node", - coalesce( - if(current_operation, label("current_operation", content)), - label("normal", content), - ) -) -''' - builtin_log_node = ''' -label_log_node( +label("node", coalesce( - if(!self, "~"), - if(current_working_copy, "@"), - if(immutable, "◆"), - if(conflict, "×"), - "○", + if(!self, label("elided", "~")), + label( + separate(" ", + if(current_working_copy, "working_copy"), + if(immutable, "immutable"), + if(conflict, "conflict"), + ), + coalesce( + if(!self, "~"), + if(current_working_copy, "@"), + if(immutable, "◆"), + if(conflict, "×"), + "○", + ) + ) ) ) ''' builtin_log_node_ascii = ''' -label_log_node( +label("node", coalesce( - if(!self, "~"), - if(current_working_copy, "@"), - if(immutable, "#"), - if(conflict, "x"), - "o", + if(!self, label("elided", "~")), + label( + separate(" ", + if(current_working_copy, "working_copy"), + if(immutable, "immutable"), + if(conflict, "conflict"), + ), + coalesce( + if(!self, "~"), + if(current_working_copy, "@"), + if(immutable, "#"), + if(conflict, "x"), + "o", + ) + ) ) ) ''' builtin_op_log_node = ''' -label_op_log_node( +label("node", coalesce( - if(current_operation, "@"), + if(current_operation, label("current_operation", "@")), "○", ) ) ''' builtin_op_log_node_ascii = ''' -label_op_log_node( +label("node", coalesce( - if(current_operation, "@"), + if(current_operation, label("current_operation", "@")), "o", ) )