From 859b0f680cee31404092e55f8c50965980316d7b Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 15 Feb 2023 19:19:41 -0800 Subject: [PATCH] Make `ui.relative-timestamps` default to true This seems like a better default for `jj op log`, which is now the only thing this option affects. --- CHANGELOG.md | 4 ++-- lib/src/settings.rs | 2 +- src/config-schema.json | 4 ++-- tests/test_concurrent_operations.rs | 8 ++++---- tests/test_operations.rs | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96549ebb0..fbfcdc825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Use the `format_timestamp()` template alias instead. For details, see [the documentation](docs/config.md). +* `jj op log` now shows relative timestamps by default. To disable, set `ui.relative-timestamps` to `false`. + * 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 @@ -85,8 +87,6 @@ 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 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 `~/.jjconfig.toml`. diff --git a/lib/src/settings.rs b/lib/src/settings.rs index 89b189e26..ceb2174e7 100644 --- a/lib/src/settings.rs +++ b/lib/src/settings.rs @@ -161,7 +161,7 @@ impl UserSettings { pub fn relative_timestamps(&self) -> bool { self.config .get_bool("ui.relative-timestamps") - .unwrap_or(false) + .unwrap_or(true) } pub fn config(&self) -> &config::Config { diff --git a/src/config-schema.json b/src/config-schema.json index aade1fac6..1d4f4b256 100644 --- a/src/config-schema.json +++ b/src/config-schema.json @@ -53,8 +53,8 @@ }, "relative-timestamps": { "type": "boolean", - "description": "Whether to change timestamps to be rendered as a relative description instead of a full timestamp", - "default": false + "description": "Whether to change timestamps in the op log to be rendered as a relative description instead of a full timestamp", + "default": true }, "default-revset": { "type": "string", diff --git a/tests/test_concurrent_operations.rs b/tests/test_concurrent_operations.rs index cdeddab08..e6089513c 100644 --- a/tests/test_concurrent_operations.rs +++ b/tests/test_concurrent_operations.rs @@ -51,14 +51,14 @@ fn test_concurrent_operations_auto_rebase() { test_env.jj_cmd_success(&repo_path, &["describe", "-m", "initial"]); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); insta::assert_snapshot!(stdout, @r###" - @ eac5ad986688 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + @ eac5ad986688 test-username@host.example.com 22 years ago, lasted less than a microsecond │ describe commit 123ed18e4c4c0d77428df41112bc02ffc83fb935 │ args: jj describe -m initial - o 09a674690d20 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 + o 09a674690d20 test-username@host.example.com 22 years ago, lasted less than a microsecond │ snapshot working copy - o a99a3fd5c51e test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + o a99a3fd5c51e test-username@host.example.com 22 years ago, lasted less than a microsecond │ add workspace 'default' - o 56b94dfc38e7 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 + o 56b94dfc38e7 test-username@host.example.com 22 years ago, lasted less than a microsecond initialize repo "###); let op_id_hex = stdout[3..15].to_string(); diff --git a/tests/test_operations.rs b/tests/test_operations.rs index 8fc005903..a529f1fc0 100644 --- a/tests/test_operations.rs +++ b/tests/test_operations.rs @@ -27,7 +27,10 @@ fn test_op_log() { let repo_path = test_env.env_root().join("repo"); test_env.jj_cmd_success(&repo_path, &["describe", "-m", "description 0"]); - let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); + let stdout = test_env.jj_cmd_success( + &repo_path, + &["op", "log", "--config-toml", "ui.relative-timestamps=false"], + ); insta::assert_snapshot!(&stdout, @r###" @ 45108169c0f8 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 │ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22 @@ -38,10 +41,7 @@ fn test_op_log() { initialize repo "###); // Test op log with relative dates - let stdout = test_env.jj_cmd_success( - &repo_path, - &["op", "log", "--config-toml", "ui.relative-timestamps=true"], - ); + let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); let regex = Regex::new(r"\d\d years").unwrap(); insta::assert_snapshot!(regex.replace_all(&stdout, "NN years"), @r###" @ 45108169c0f8 test-username@host.example.com NN years ago, lasted less than a microsecond