cli: actually test if format_short_change_id() can be parsed

It's usually included in the commit_summary template, but not guaranteed.
This commit is contained in:
Yuya Nishihara 2024-09-13 21:27:27 +09:00
parent 62059dd91e
commit 41ef9a76de

View file

@ -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<Rc<tracing_chrome::FlushGuard>>,
@ -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()")
}