forked from mirrors/jj
config: remove ui.log-author-format in favor of template alias
This commit is contained in:
parent
6316ec7442
commit
3c61e9239c
6 changed files with 9 additions and 111 deletions
|
@ -155,8 +155,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* `author`/`committer` templates now support `.username()`, which leaves out the
|
||||
domain information of `.email()`.
|
||||
|
||||
* It is now possible to change the author format of `jj log` with the new
|
||||
`ui.log-author-format` option.
|
||||
* It is now possible to change the author format of `jj log` with the
|
||||
`format_short_signature()` template alias. For details, see
|
||||
[the documentation](docs/config.md).
|
||||
|
||||
* Added support for template aliases. New symbols and functions can be
|
||||
configured by `template-aliases.<name> = <expression>`. Be aware that
|
||||
|
|
|
@ -164,12 +164,6 @@ impl UserSettings {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn log_author_format(&self) -> String {
|
||||
self.config
|
||||
.get_string("ui.log-author-format")
|
||||
.unwrap_or_else(|_| "email".to_owned())
|
||||
}
|
||||
|
||||
pub fn config(&self) -> &config::Config {
|
||||
&self.config
|
||||
}
|
||||
|
|
|
@ -1544,21 +1544,6 @@ fn load_template_aliases(
|
|||
) -> Result<TemplateAliasesMap, CommandError> {
|
||||
const TABLE_KEY: &str = "template-aliases";
|
||||
let mut aliases_map = TemplateAliasesMap::new();
|
||||
|
||||
// TODO: Reorganize default template aliases and config knobs:
|
||||
// - remove these configs and let user override aliases?
|
||||
// - separate namespace or config section for these "default" aliases? but how?
|
||||
let signature_template = match settings.log_author_format().as_str() {
|
||||
"none" => r#""""#,
|
||||
"full" => "signature",
|
||||
"name" => "signature.name()",
|
||||
"username" => "signature.username()",
|
||||
_ => "signature.email()",
|
||||
};
|
||||
aliases_map
|
||||
.insert("format_short_signature(signature)", signature_template)
|
||||
.unwrap();
|
||||
|
||||
let table = settings.config().get_table(TABLE_KEY)?;
|
||||
for (decl, value) in table.into_iter().sorted_by(|a, b| a.0.cmp(&b.0)) {
|
||||
let r = value
|
||||
|
|
|
@ -107,17 +107,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"log-author-format": {
|
||||
"enum": [
|
||||
"none",
|
||||
"full",
|
||||
"name",
|
||||
"username",
|
||||
"email"
|
||||
],
|
||||
"default": "email",
|
||||
"description": "Determines how author information is displayed in `jj log`"
|
||||
},
|
||||
"editor": {
|
||||
"type": "string",
|
||||
"description": "Editor to use for commands that involve editing text"
|
||||
|
|
|
@ -34,6 +34,7 @@ show = 'show'
|
|||
|
||||
# Hook points for users to customize the default templates:
|
||||
'format_short_id(id)' = 'id.shortest(12)'
|
||||
'format_short_signature(signature)' = 'signature.email()'
|
||||
'format_timestamp(timestamp)' = 'timestamp'
|
||||
|
||||
# TODO: Add branches, tags, etc
|
||||
|
|
|
@ -561,7 +561,7 @@ fn test_log_shortest_length_parameter() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_log_author_format_in_default_template() {
|
||||
fn test_log_author_format() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
|
@ -574,91 +574,19 @@ fn test_log_author_format_in_default_template() {
|
|||
~
|
||||
"###
|
||||
);
|
||||
|
||||
let decl = "template-aliases.'format_short_signature(signature)'";
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
&[
|
||||
"--config-toml=ui.log-author-format=''",
|
||||
"--config-toml",
|
||||
&format!("{decl}='signature.username()'"),
|
||||
"log",
|
||||
"--revisions=@",
|
||||
],
|
||||
),
|
||||
@r###"
|
||||
@ qpvuntsmwlqt test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
|
||||
│ (empty) (no description set)
|
||||
~
|
||||
"###
|
||||
);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
&[
|
||||
"--config-toml=ui.log-author-format='gibberish'",
|
||||
"log",
|
||||
"--revisions=@",
|
||||
],
|
||||
),
|
||||
@r###"
|
||||
@ qpvuntsmwlqt test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
|
||||
│ (empty) (no description set)
|
||||
~
|
||||
"###
|
||||
);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
&[
|
||||
"--config-toml=ui.log-author-format='email'",
|
||||
"log",
|
||||
"--revisions=@",
|
||||
],
|
||||
),
|
||||
@r###"
|
||||
@ qpvuntsmwlqt test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
|
||||
│ (empty) (no description set)
|
||||
~
|
||||
"###
|
||||
);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
&[
|
||||
"--config-toml=ui.log-author-format='none'",
|
||||
"log",
|
||||
"--revisions=@",
|
||||
],
|
||||
),
|
||||
@r###"
|
||||
@ qpvuntsmwlqt 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
|
||||
│ (empty) (no description set)
|
||||
~
|
||||
"###
|
||||
);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
&[
|
||||
"--config-toml=ui.log-author-format='name'",
|
||||
"log",
|
||||
"--revisions=@"
|
||||
],
|
||||
),
|
||||
@r###"
|
||||
@ qpvuntsmwlqt Test User 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
|
||||
│ (empty) (no description set)
|
||||
~
|
||||
"###
|
||||
);
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
&[
|
||||
"--config-toml=ui.log-author-format='username'",
|
||||
"log",
|
||||
"--revisions=@"
|
||||
],
|
||||
),
|
||||
@r###"
|
||||
@ qpvuntsmwlqt test.user 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
|
||||
│ (empty) (no description set)
|
||||
~
|
||||
|
|
Loading…
Reference in a new issue