Added a new section to the global config file, template
. It has two fields:
message
and description
, pointing to files with the contents of
corresponding fields for pijul record
.
Analogous to git's commit.template
, except that pijul
separates the title
from the description.
The config file is now parsed unconditionally: previously it was used only for
fallbacks, but description
was never set to anything, making the config the
primary source.
Errors out if a file was specified in the config but could not be read.
TFPETWTVADLG2DL7WERHJPGMJVOY4WOKCRWB3NZ3YOOQ4CVAUHBAC
ChangeHeader {
message: self.message.clone().unwrap_or_else(String::new),
let templates = config.as_ref().ok().and_then(|cfg| cfg.template.as_ref());
let message = if let Some(message) = &self.message {
message.clone()
} else if let Some(message_file) = templates.and_then(|t| t.message.as_ref()) {
match std::fs::read_to_string(message_file) {
Ok(m) => m,
Err(e) => bail!("Could not read message template: {:?}: {}", message_file, e),
}
} else {
String::new()
};
let description = if let Some(descr_file) = templates.and_then(|t| t.description.as_ref()) {
match std::fs::read_to_string(descr_file) {
Ok(d) => Some(d),
Err(e) => bail!(
"Could not read description template: {:?}: {}",
descr_file,
e
),
}
} else {
None
};
let header = ChangeHeader {
message,