ok/jj
1
0
Fork 0
forked from mirrors/jj

config: rename [template] section to [templates], drop .graph suffix

This should be more consistent with the other tables.
This commit is contained in:
Yuya Nishihara 2023-02-14 23:55:30 +09:00
parent 9c6fa67b86
commit 605eb72883
5 changed files with 12 additions and 17 deletions

View file

@ -34,7 +34,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Use `if(description, description, "(no description set)\n")` to get back
the previous behavior.
* If a custom `template.log.graph` template is set, working-copy commit will
* The `template.log.graph` and `template.commit_summary` config keys were
renamed to `templates.log` and `templates.commit_summary` respectively.
* If a custom `templates.log` template is set, working-copy commit will
no longer be highlighted automatically. Wrap your template with
`label(if(current_working_copy, "working_copy"), ...)` to label the
working-copy entry.

View file

@ -1599,7 +1599,7 @@ fn parse_commit_summary_template<'a>(
aliases_map: &TemplateAliasesMap,
settings: &UserSettings,
) -> Result<Box<dyn Template<Commit> + 'a>, CommandError> {
let template_text = settings.config().get_string("template.commit_summary")?;
let template_text = settings.config().get_string("templates.commit_summary")?;
Ok(template_parser::parse_commit_template(
repo,
workspace_id,

View file

@ -1278,7 +1278,7 @@ fn cmd_diff(ui: &mut Ui, command: &CommandHelper, args: &DiffArgs) -> Result<(),
fn cmd_show(ui: &mut Ui, command: &CommandHelper, args: &ShowArgs) -> Result<(), CommandError> {
let workspace_command = command.workspace_helper(ui)?;
let commit = workspace_command.resolve_single_rev(&args.revision)?;
let template_string = command.settings().config().get_string("template.show")?;
let template_string = command.settings().config().get_string("templates.show")?;
let template = workspace_command.parse_commit_template(&template_string)?;
ui.request_pager();
let mut formatter = ui.stdout_formatter();
@ -1419,10 +1419,7 @@ fn cmd_log(ui: &mut Ui, command: &CommandHelper, args: &LogArgs) -> Result<(), C
let template_string = match &args.template {
Some(value) => value.to_string(),
None => command
.settings()
.config()
.get_string("template.log.graph")?,
None => command.settings().config().get_string("templates.log")?,
};
let template = workspace_command.parse_commit_template(&template_string)?;
@ -1555,10 +1552,7 @@ fn cmd_obslog(ui: &mut Ui, command: &CommandHelper, args: &ObslogArgs) -> Result
let template_string = match &args.template {
Some(value) => value.to_string(),
None => command
.settings()
.config()
.get_string("template.log.graph")?,
None => command.settings().config().get_string("templates.log")?,
};
let template = workspace_command.parse_commit_template(&template_string)?;

View file

@ -1,12 +1,10 @@
# TODO: rename section to [templates]?
[template]
[templates]
commit_summary = '''
format_short_id(commit_id) " "
if(description, description.first_line(), description_placeholder)
'''
# TODO: drop '.graph'?
log.graph = '''
log = '''
label(if(current_working_copy, "working_copy"),
separate(" ",
if(divergent,

View file

@ -216,8 +216,8 @@ fn test_list_workspaces_template() {
test_env.jj_cmd_success(test_env.env_root(), &["init", "--git", "main"]);
test_env.add_config(
r#"
template.commit_summary = """commit_id.short() " " description.first_line()
if(current_working_copy, " (current)")"""
templates.commit_summary = """commit_id.short() " " description.first_line()
if(current_working_copy, " (current)")"""
"#,
);
let main_path = test_env.env_root().join("main");