Skip to content

Commit

Permalink
templates: extract common parts from commit_summary templates
Browse files Browse the repository at this point in the history
If "branch"/"tag list" are migrate to templates, the added alias function
will be called from these templates.
  • Loading branch information
yuja committed Apr 25, 2024
1 parent 29bd371 commit 50d18f4
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -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()),
Expand Down

0 comments on commit 50d18f4

Please sign in to comment.