Skip to content

Commit 20a5d2b

Browse files
committed
Accurately show status when downgrading dependencies
1 parent d4249c9 commit 20a5d2b

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

crates/cargo-test-support/src/compare.rs

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ fn substitute_macros(input: &str) -> String {
192192
("[CHECKING]", " Checking"),
193193
("[COMPLETED]", " Completed"),
194194
("[CREATED]", " Created"),
195+
("[DOWNGRADING]", " Downgrading"),
195196
("[FINISHED]", " Finished"),
196197
("[ERROR]", "error:"),
197198
("[WARNING]", "warning:"),

src/cargo/ops/cargo_generate_lockfile.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::util::CargoResult;
88
use anyhow::Context;
99
use log::debug;
1010
use std::collections::{BTreeMap, HashSet};
11-
use termcolor::Color::{self, Cyan, Green, Red};
11+
use termcolor::Color::{self, Cyan, Green, Red, Yellow};
1212

1313
pub struct UpdateOptions<'a> {
1414
pub config: &'a Config,
@@ -142,7 +142,12 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
142142
} else {
143143
format!("{} -> v{}", removed[0], added[0].version())
144144
};
145-
print_change("Updating", msg, Green)?;
145+
146+
if removed[0].version() > added[0].version() {
147+
print_change("Downgrading", msg, Yellow)?;
148+
} else {
149+
print_change("Updating", msg, Green)?;
150+
}
146151
} else {
147152
for package in removed.iter() {
148153
print_change("Removing", format!("{}", package), Red)?;

tests/testsuite/offline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ fn main(){
657657
.with_status(0)
658658
.with_stderr(
659659
"\
660-
[UPDATING] present_dep v1.2.9 -> v1.2.3
660+
[DOWNGRADING] present_dep v1.2.9 -> v1.2.3
661661
",
662662
)
663663
.run();

tests/testsuite/update.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ fn update_precise() {
385385
.with_stderr(
386386
"\
387387
[UPDATING] `[..]` index
388-
[UPDATING] serde v0.2.1 -> v0.2.0
388+
[DOWNGRADING] serde v0.2.1 -> v0.2.0
389389
",
390390
)
391391
.run();
@@ -492,7 +492,7 @@ fn update_precise_first_run() {
492492
.with_stderr(
493493
"\
494494
[UPDATING] `[..]` index
495-
[UPDATING] serde v0.2.1 -> v0.2.0
495+
[DOWNGRADING] serde v0.2.1 -> v0.2.0
496496
",
497497
)
498498
.run();

0 commit comments

Comments
 (0)