Skip to content

Commit

Permalink
cli: actually test if format_short_change_id() can be parsed
Browse files Browse the repository at this point in the history
It's usually included in the commit_summary template, but not guaranteed.
  • Loading branch information
yuja committed Sep 13, 2024
1 parent 62059dd commit 41ef9a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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()")
}

Expand Down

0 comments on commit 41ef9a7

Please sign in to comment.