diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index da1d0992c7ab..3a60ac5d789f 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -192,6 +192,7 @@ fn substitute_macros(input: &str) -> String { ("[CHECKING]", " Checking"), ("[COMPLETED]", " Completed"), ("[CREATED]", " Created"), + ("[DOWNGRADING]", " Downgrading"), ("[FINISHED]", " Finished"), ("[ERROR]", "error:"), ("[WARNING]", "warning:"), diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 04d4010f45e4..e9757c9c5c9e 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -8,7 +8,7 @@ use crate::util::CargoResult; use anyhow::Context; use log::debug; use std::collections::{BTreeMap, HashSet}; -use termcolor::Color::{self, Cyan, Green, Red}; +use termcolor::Color::{self, Cyan, Green, Red, Yellow}; pub struct UpdateOptions<'a> { pub config: &'a Config, @@ -142,7 +142,12 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes } else { format!("{} -> v{}", removed[0], added[0].version()) }; - print_change("Updating", msg, Green)?; + + if removed[0].version() < added[0].version() { + print_change("Updating", msg, Green)?; + } else { + print_change("Downgrading", msg, Yellow)?; + } } else { for package in removed.iter() { print_change("Removing", format!("{}", package), Red)?; diff --git a/tests/testsuite/offline.rs b/tests/testsuite/offline.rs index a69137b95907..fe54fc59df8f 100644 --- a/tests/testsuite/offline.rs +++ b/tests/testsuite/offline.rs @@ -657,7 +657,7 @@ fn main(){ .with_status(0) .with_stderr( "\ -[UPDATING] present_dep v1.2.9 -> v1.2.3 +[DOWNGRADING] present_dep v1.2.9 -> v1.2.3 ", ) .run(); diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index a2105ba3efe7..057c8fca4a3a 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -385,7 +385,7 @@ fn update_precise() { .with_stderr( "\ [UPDATING] `[..]` index -[UPDATING] serde v0.2.1 -> v0.2.0 +[DOWNGRADING] serde v0.2.1 -> v0.2.0 ", ) .run(); @@ -492,7 +492,7 @@ fn update_precise_first_run() { .with_stderr( "\ [UPDATING] `[..]` index -[UPDATING] serde v0.2.1 -> v0.2.0 +[DOWNGRADING] serde v0.2.1 -> v0.2.0 ", ) .run();