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.
This commit is contained in:
Yuya Nishihara 2024-04-25 17:40:32 +09:00
parent 2bd6983003
commit dbc7ad2d8e

View file

@ -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()),