forked from mirrors/jj
templater: display both name and email by author/committer keywords
This is an example of labeled output of structured value types. I think "{name} <{email}>" is a good default formatting, but I should note that the signature also contains timestamp field.
This commit is contained in:
parent
4e661ecd40
commit
47e6ceb5fa
3 changed files with 10 additions and 3 deletions
|
@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* `jj log` prefixes commit descriptions with "(empty)" when they contain no
|
||||
change compared to their parents.
|
||||
|
||||
* The `author`/`committer` templates now display both name and email. Use
|
||||
`author.name()`/`committer.name()` to extract the name.
|
||||
|
||||
### New features
|
||||
|
||||
* The default log format now uses the committer timestamp instead of the author
|
||||
|
|
|
@ -1233,8 +1233,8 @@ fn cmd_show(ui: &mut Ui, command: &CommandHelper, args: &ShowArgs) -> Result<(),
|
|||
r#"
|
||||
"Commit ID: " commit_id "\n"
|
||||
"Change ID: " change_id "\n"
|
||||
"Author: " author " <" author.email() "> (" {author_timestamp_template} ")\n"
|
||||
"Committer: " committer " <" committer.email() "> (" {committer_timestamp_template} ")\n"
|
||||
"Author: " author " (" {author_timestamp_template} ")\n"
|
||||
"Committer: " committer " (" {committer_timestamp_template} ")\n"
|
||||
"\n"
|
||||
description
|
||||
"\n""#,
|
||||
|
|
|
@ -33,7 +33,11 @@ pub trait Template<C> {
|
|||
|
||||
impl Template<()> for Signature {
|
||||
fn format(&self, _: &(), formatter: &mut dyn Formatter) -> io::Result<()> {
|
||||
formatter.write_str(&self.name)
|
||||
write!(formatter, "{}", self.name)?;
|
||||
write!(formatter, " <")?;
|
||||
write!(formatter.labeled("email"), "{}", self.email)?;
|
||||
write!(formatter, ">")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue