From 5d2f17b8acebc21983b149b4891989071e03f783 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 26 Oct 2023 22:42:32 -0700 Subject: [PATCH] cli version: Put `+` before build data instead of `-` Replace `jj 0.10.0-20231027-bb8af5adc4f98ff2` with `jj 0.10.0+20231027-bb8af5adc4f98ff2`. According to https://semver.org, the build metadata should be separated by a `+`, not `-`. If semver rules are pedantically followed, `jj 0.10.0-20231027-bb8af5adc4f98ff2` sorts before `jj 0.10.0`, whereas the build metadata is ignored for the purposes of ordering. I'm not sure whether anybody else is likely to treat the full `jj version` string as a semver this pendantically, but we can :). I discovered this when thinking about #2258; see that PR for a few more details about pedantic semvers. --- cli/build.rs | 2 +- cli/tests/test_global_opts.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/build.rs b/cli/build.rs index 942c616981..d949b02c6e 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -47,7 +47,7 @@ fn main() -> std::io::Result<()> { if let Some((mut git_hash, maybe_date)) = get_git_timestamp_and_hash() { git_hash.truncate(16); println!( - "cargo:rustc-env=JJ_VERSION={}-{}-{}", + "cargo:rustc-env=JJ_VERSION={}+{}-{}", version, maybe_date .map(|d| d.format("%Y%m%d").to_string()) diff --git a/cli/tests/test_global_opts.rs b/cli/tests/test_global_opts.rs index 1a5ace844e..10ac8794c8 100644 --- a/cli/tests/test_global_opts.rs +++ b/cli/tests/test_global_opts.rs @@ -48,9 +48,9 @@ fn test_version() { let sanitized = stdout.replace(|c: char| c.is_ascii_hexdigit(), "?"); let expected = [ "jj ?.??.?\n", - "jj ?.??.?-????????-????????????????\n", + "jj ?.??.?+????????-????????????????\n", // `dateunknown` turns into `??t?unknown` since d,a,e are hex digits. - "jj ?.??.?-??t?unknown-????????????????\n", + "jj ?.??.?+??t?unknown-????????????????\n", ]; assert!( expected.contains(&sanitized.as_str()),