ok/jj
1
0
Fork 0
forked from mirrors/jj

config: extract commit_summary template to config/templates.toml

This commit is contained in:
Yuya Nishihara 2023-02-14 14:12:06 +09:00
parent e996f6859b
commit bc7ca03da4
2 changed files with 13 additions and 13 deletions

View file

@ -1598,19 +1598,14 @@ fn parse_commit_summary_template<'a>(
workspace_id: &WorkspaceId,
aliases_map: &TemplateAliasesMap,
settings: &UserSettings,
) -> Result<Box<dyn Template<Commit> + 'a>, TemplateParseError> {
settings
.config()
.get_string("template.commit_summary")
.ok()
.map(|s| template_parser::parse_commit_template(repo, workspace_id, &s, aliases_map))
.unwrap_or_else(|| {
let s = r#"
commit_id.short() " "
if(description, description.first_line(), description_placeholder)
"#;
template_parser::parse_commit_template(repo, workspace_id, s, aliases_map)
})
) -> Result<Box<dyn Template<Commit> + 'a>, CommandError> {
let template_text = settings.config().get_string("template.commit_summary")?;
Ok(template_parser::parse_commit_template(
repo,
workspace_id,
&template_text,
aliases_map,
)?)
}
// TODO: Use a proper TOML library to serialize instead.

View file

@ -1,5 +1,10 @@
# TODO: rename section to [templates]?
[template]
commit_summary = '''
commit_id.short() " "
if(description, description.first_line(), description_placeholder)
'''
# TODO: drop '.graph'?
log.graph = '''
label(if(current_working_copy, "working_copy"),