Skip to content

Commit 1dc678b

Browse files
committed
cli: Fix update message for rustup itself
Signed-off-by: Daniel Silverstone <[email protected]>
1 parent 11d6b20 commit 1dc678b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/cli/common.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn show_channel_updates(
183183
) -> Result<()> {
184184
let data = toolchains.into_iter().map(|(name, result)| {
185185
let toolchain = cfg.get_toolchain(&name, false).unwrap();
186-
let version = toolchain.rustc_version();
186+
let mut version: String = toolchain.rustc_version().into();
187187

188188
let banner;
189189
let color;
@@ -194,11 +194,19 @@ fn show_channel_updates(
194194
color = Some(term2::color::GREEN);
195195
}
196196
Ok(UpdateStatus::Updated(v)) => {
197-
previous_version = Some(v);
197+
if name == "rustup" {
198+
previous_version = Some(env!("CARGO_PKG_VERSION").into());
199+
version = v;
200+
} else {
201+
previous_version = Some(v);
202+
}
198203
banner = "updated";
199204
color = Some(term2::color::GREEN);
200205
}
201206
Ok(UpdateStatus::Unchanged) => {
207+
if name == "rustup" {
208+
version = env!("CARGO_PKG_VERSION").into();
209+
}
202210
banner = "unchanged";
203211
color = None;
204212
}

tests/cli-self-upd.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,7 @@ info: downloading self-update
579579
expect_ok_ex(
580580
config,
581581
&["rustup", "self", "update"],
582-
&format!(
583-
" rustup updated - (toolchain not installed) (from {})\n\n",
584-
version,
585-
),
582+
&format!(" rustup updated - {} (from {})\n\n", version, version,),
586583
&expected_output,
587584
)
588585
});
@@ -706,9 +703,12 @@ fn update_no_change() {
706703
expect_ok_ex(
707704
config,
708705
&["rustup", "self", "update"],
709-
r" rustup unchanged - (toolchain not installed)
706+
&format!(
707+
r" rustup unchanged - {}
710708
711709
",
710+
version
711+
),
712712
r"info: checking for self-updates
713713
",
714714
);

0 commit comments

Comments
 (0)