From bc7ca03da400f5f99fe54788ae1f061de324dfd7 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 14 Feb 2023 14:12:06 +0900 Subject: [PATCH] config: extract commit_summary template to config/templates.toml --- src/cli_util.rs | 21 ++++++++------------- src/config/templates.toml | 5 +++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cli_util.rs b/src/cli_util.rs index 1533303dd..b2e33b645 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -1598,19 +1598,14 @@ fn parse_commit_summary_template<'a>( workspace_id: &WorkspaceId, aliases_map: &TemplateAliasesMap, settings: &UserSettings, -) -> Result + '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 + '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. diff --git a/src/config/templates.toml b/src/config/templates.toml index a99d66920..d1f46b9bd 100644 --- a/src/config/templates.toml +++ b/src/config/templates.toml @@ -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"),