diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b2be1ddd..8b5c72f3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/cli_util.rs b/src/cli_util.rs index b2e33b645..e5745e2fc 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -1599,7 +1599,7 @@ fn parse_commit_summary_template<'a>( aliases_map: &TemplateAliasesMap, settings: &UserSettings, ) -> Result + '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, diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 4325e42b6..857a4addd 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -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)?; diff --git a/src/config/templates.toml b/src/config/templates.toml index 87f8e8065..b1863a6c3 100644 --- a/src/config/templates.toml +++ b/src/config/templates.toml @@ -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, diff --git a/tests/test_workspaces.rs b/tests/test_workspaces.rs index fc146a688..ea763d959 100644 --- a/tests/test_workspaces.rs +++ b/tests/test_workspaces.rs @@ -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");