Skip to content

Commit

Permalink
cli: extract function that creates CommitTemplateLanguage for the wor…
Browse files Browse the repository at this point in the history
…kspace

cmd_log() will parse the text and graph node templates by using the shared
language environment.
  • Loading branch information
yuja committed Mar 18, 2024
1 parent 8c633f5 commit 6d8420e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,15 +912,20 @@ Set which revision the branch points to with `jj branch set {branch_name} -r <RE
}
}

let language = CommitTemplateLanguage::new(
let language = self.commit_template_language()?;
let inner_template = self.parse_template(&language, template_text)?;
Ok(Box::new(TemplateWrapper(inner_template)))
}

/// Creates commit template language environment for this workspace.
pub fn commit_template_language(&self) -> Result<CommitTemplateLanguage<'_>, CommandError> {
Ok(CommitTemplateLanguage::new(
self.repo().as_ref(),
self.workspace_id(),
self.revset_parse_context(),
self.id_prefix_context()?,
self.commit_template_extension.as_deref(),
);
let inner_template = self.parse_template(&language, template_text)?;
Ok(Box::new(TemplateWrapper(inner_template)))
))
}

/// Template for one-line summary of a commit.
Expand Down

0 comments on commit 6d8420e

Please sign in to comment.