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 Nov 4, 2023
1 parent 9083b6b commit 8af3282
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 @@ -72,10 +72,10 @@ fn test_no_subcommand() {
assert_matches!(
sanitized.as_str(),
"jj ?.??.?\n"
| "jj ?.??.?-????????-????????????????\n"
| "jj ?.??.?+????????-????????????????\n"
// `dateunknown` turns into `??t?unknown` since d,a,e are hex digits.
// TODO(ilyagr): This might be clearer as a regex.
| "jj ?.??.?-??t?unknown-????????????????\n"
| "jj ?.??.?+??t?unknown-????????????????\n"
);

let stdout = test_env.jj_cmd_success(test_env.env_root(), &["-R", "repo"]);
Expand Down

0 comments on commit 8af3282

Please sign in to comment.