Skip to content

Commit 985e1ee

Browse files
committed
Do not call it "Downgrading" when difference is only build metadata
1 parent 4d1bf29 commit 985e1ee

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,15 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
152152
format!("{} -> v{}", removed[0], added[0].version())
153153
};
154154

155-
if removed[0].version() > added[0].version() {
155+
// If versions differ only in build metadata, we call it an "update"
156+
// regardless of whether the build metadata has gone up or down.
157+
// This metadata is often stuff like git commit hashes, which are
158+
// not meaningfully ordered.
159+
let removed = removed[0].version();
160+
let added = added[0].version();
161+
if (removed.major, removed.minor, removed.patch, &removed.pre)
162+
> (added.major, added.minor, added.patch, &added.pre)
163+
{
156164
print_change("Downgrading", msg, &style::WARN)?;
157165
} else {
158166
print_change("Updating", msg, &style::GOOD)?;

tests/testsuite/update.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,13 @@ fn update_precise_build_metadata() {
423423
)
424424
.run();
425425

426+
// This is not considered "Downgrading". Build metadata are not assumed to
427+
// be ordered.
426428
p.cargo("update serde --precise 0.0.1+first")
427429
.with_stderr(
428430
"\
429431
[UPDATING] `[..]` index
430-
[DOWNGRADING] serde v0.0.1+second -> v0.0.1+first
432+
[UPDATING] serde v0.0.1+second -> v0.0.1+first
431433
",
432434
)
433435
.run();

0 commit comments

Comments
 (0)