From dbc7ad2d8e06e5ae1bd87f8dd638c4e957090f52 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 25 Apr 2024 17:40:32 +0900 Subject: [PATCH] templates: extract common parts from commit_summary templates If "branch"/"tag list" are migrate to templates, the added alias function will be called from these templates. --- cli/src/config/templates.toml | 41 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 1a93949ef..033d74909 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -1,28 +1,6 @@ [templates] -commit_summary = ''' -separate(" ", - format_short_change_id_with_hidden_and_divergent_info(self), - format_short_commit_id(commit_id), - separate(commit_summary_separator, - branches, - separate(" ", - if(conflict, label("conflict", "(conflict)")), - if(empty, label("empty", "(empty)")), - if(description, description.first_line(), description_placeholder), - ) - ) -) -''' - -commit_summary_no_branches = ''' -separate(" ", - format_short_change_id_with_hidden_and_divergent_info(self), - format_short_commit_id(commit_id), - if(conflict, label("conflict", "(conflict)")), - if(empty, label("empty", "(empty)")), - if(description, description.first_line(), description_placeholder), -) -''' +commit_summary = 'format_commit_summary_with_refs(self, branches)' +commit_summary_no_branches = 'format_commit_summary_with_refs(self, "")' config_list = ''' label(if(overridden, "overridden"), @@ -133,6 +111,21 @@ commit_summary_separator = 'label("separator", " | ")' time_range.start().ago() ++ label("time", ", lasted ") ++ time_range.duration()''' 'format_timestamp(timestamp)' = 'timestamp.local().format("%Y-%m-%d %H:%M:%S")' +'format_commit_summary_with_refs(commit, refs)' = ''' +separate(" ", + format_short_change_id_with_hidden_and_divergent_info(commit), + format_short_commit_id(commit.commit_id()), + separate(commit_summary_separator, + refs, + separate(" ", + if(commit.conflict(), label("conflict", "(conflict)")), + if(commit.empty(), label("empty", "(empty)")), + if(commit.description(), commit.description().first_line(), description_placeholder), + ), + ), +) +''' + 'format_root_commit(root)' = ''' separate(" ", format_short_change_id(root.change_id()),