From 41ef9a76de25a691cb0e7a3ae53f6c8a06d9821f Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 13 Sep 2024 21:27:27 +0900 Subject: [PATCH] cli: actually test if format_short_change_id() can be parsed It's usually included in the commit_summary template, but not guaranteed. --- cli/src/cli_util.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 6263fd434e..c39e8805f5 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -169,6 +169,8 @@ use crate::text_util; use crate::ui::ColorChoice; use crate::ui::Ui; +const SHORT_CHANGE_ID_TEMPLATE_TEXT: &str = "format_short_change_id(self.change_id())"; + #[derive(Clone)] struct ChromeTracingFlushGuard { _inner: Option>, @@ -751,6 +753,7 @@ impl WorkspaceCommandHelper { // Parse commit_summary template early to report error before starting // mutable operation. helper.parse_commit_template(&helper.commit_summary_template_text)?; + helper.parse_commit_template(SHORT_CHANGE_ID_TEMPLATE_TEXT)?; Ok(helper) } @@ -1297,7 +1300,7 @@ impl WorkspaceCommandHelper { } pub fn short_change_id_template(&self) -> TemplateRenderer<'_, Commit> { - self.parse_commit_template("format_short_change_id(self.change_id())") + self.parse_commit_template(SHORT_CHANGE_ID_TEMPLATE_TEXT) .expect("parse error should be confined by WorkspaceCommandHelper::new()") }