diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d0bfcb9c..e808d1733 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `label(if(current_working_copy, "working_copy"), ...)` to label the working-copy entry. +* `jj log` and `jj show` no longer respect `ui.relative-timestamps = true`. + Use the `format_timestamp()` template alias instead. For details, see + [the documentation](docs/config.md). + * The global `--no-commit-working-copy` is now called `--ignore-working-copy`. * The `diff.format` config option is now called `ui.diff.format`. The old name @@ -81,7 +85,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Per-repository configuration is now read from `.jj/repo/config.toml`. -* The `ui.relative-timestamps` option now also affects `jj op log`. +* The `ui.relative-timestamps` option now affects `jj op log`. * Background colors, bold text, and underlining are now supported. You can set e.g. `color.error = { bg = "red", bold = true, underline = true }` in your diff --git a/src/cli_util.rs b/src/cli_util.rs index e85a000c6..04ee8370e 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -1548,15 +1548,6 @@ fn load_template_aliases( // 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 timestamp_template = if settings.relative_timestamps() { - "timestamp.ago()" - } else { - "timestamp" - }; - aliases_map - .insert("format_timestamp(timestamp)", timestamp_template) - .unwrap(); - let signature_template = match settings.log_author_format().as_str() { "none" => r#""""#, "full" => "signature", diff --git a/src/config/templates.toml b/src/config/templates.toml index c0823e42b..be7a26bc7 100644 --- a/src/config/templates.toml +++ b/src/config/templates.toml @@ -34,6 +34,7 @@ show = 'show' # Hook points for users to customize the default templates: 'format_short_id(id)' = 'id.shortest(12)' +'format_timestamp(timestamp)' = 'timestamp' # TODO: Add branches, tags, etc # TODO: Indent the description like Git does diff --git a/tests/test_show_command.rs b/tests/test_show_command.rs index 1ca805d10..9039c65f5 100644 --- a/tests/test_show_command.rs +++ b/tests/test_show_command.rs @@ -41,7 +41,12 @@ fn test_show_relative_timestamps() { test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); let repo_path = test_env.env_root().join("repo"); - test_env.add_config(r#"ui.relative-timestamps = true"#); + test_env.add_config( + r#" + [template-aliases] + 'format_timestamp(timestamp)' = 'timestamp.ago()' + "#, + ); let stdout = test_env.jj_cmd_success(&repo_path, &["show"]); let timestamp_re = Regex::new(r"\([0-9]+ years ago\)").unwrap();