Skip to content

Commit

Permalink
cli version: Put + before build data instead of -
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ilyagr committed Jun 16, 2024
1 parent 69df3a8 commit fa228d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/test_global_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit fa228d5

Please sign in to comment.