Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,10 +832,10 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<ExitCode> {
MultiProgress::with_draw_target(cfg.process.progress_draw_target());
let semaphore = Arc::new(Semaphore::new(concurrent_downloads));
let channels = tokio_stream::iter(channels.into_iter()).map(|(name, distributable)| {
let msg = format!("{bold}{name} - {bold:#}");
let status = "Checking...";
let msg = format!("{bold}{name}{bold:#}");
let status = " Checking";
let template = format!(
"{{msg}}{transient}{status}{transient:#} {transient}{{spinner}}{transient:#}"
"{transient}{status}{transient:#} {{msg}} {transient}{{spinner}}{transient:#}"
);
let pb = multi_progress_bars.add(ProgressBar::new(1));
pb.set_style(
Expand All @@ -855,22 +855,23 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<ExitCode> {

let template = match (current_version, dist_version) {
(None, None) => {
let status = "Cannot identify installed or update versions";
format!("{msg}{error}{status}{error:#}")
let status = " Error for";
let details = "cannot identify installed or update versions";
format!("{status} {msg}: {error}{details}{error:#}")
}
(Some(cv), None) => {
let status = "up to date";
format!("{msg}{good}{status}{good:#}: {cv}")
let status = " Up to date";
format!("{good}{status}{good:#} {msg} {cv}")
}
(Some(cv), Some(dv)) => {
let status = "update available";
let status = "Update available";
update_a = true;
format!("{msg}{warn}{status}{warn:#}: {cv} -> {dv}")
format!("{warn}{status}{warn:#} {msg} {cv} -> {dv}")
}
(None, Some(dv)) => {
let status = "update available";
let status = "Update available";
update_a = true;
format!("{msg}{warn}{status}{warn:#}: (Unknown version) -> {dv}")
format!("{warn}{status}{warn:#} {msg} (Unknown version) -> {dv}")
}
};
pb.set_style(ProgressStyle::with_template(template.as_str()).unwrap());
Expand Down
12 changes: 7 additions & 5 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,19 +1399,21 @@ pub(crate) async fn check_rustup_update(dl_cfg: &DownloadCfg<'_>) -> Result<bool
let available_version = get_available_rustup_version(dl_cfg).await?;

let bold = Style::new().bold();
let yellow = WARN;
let green = GOOD;
let warn = WARN;
let good = GOOD;

write!(t, "{bold}rustup - {bold:#}")?;
let msg = format!("{bold}rustup{bold:#}");

Ok(if current_version != available_version {
let status = "Update available";
writeln!(
t,
"{yellow}Update available{yellow:#} : {current_version} -> {available_version}"
"{warn}{status}{warn:#} {msg} {current_version} -> {available_version}"
)?;
true
} else {
writeln!(t, "{green}Up to date{green:#} : {current_version}")?;
let status = " Up to date";
writeln!(t, "{good}{status}{good:#} {msg} {current_version}")?;
false
})
}
Expand Down
36 changes: 18 additions & 18 deletions tests/suite/cli_exact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async fn update_once_and_check_self_update() {

nightly-[HOST_TRIPLE] installed - 1.3.0 (hash-nightly-2)

rustup - Update available : [CURRENT_VERSION] -> [TEST_VERSION]
Update available rustup [CURRENT_VERSION] -> [TEST_VERSION]

"#]])
.with_stderr(snapbox::str![[r#"
Expand Down Expand Up @@ -184,9 +184,9 @@ async fn check_updates_none() {
.await
.is_err()
.with_stdout(snapbox::str![[r#"
stable-[HOST_TRIPLE] - up to date: 1.1.0 (hash-stable-1.1.0)
beta-[HOST_TRIPLE] - up to date: 1.2.0 (hash-beta-1.2.0)
nightly-[HOST_TRIPLE] - up to date: 1.3.0 (hash-nightly-2)
Up to date stable-[HOST_TRIPLE] 1.1.0 (hash-stable-1.1.0)
Up to date beta-[HOST_TRIPLE] 1.2.0 (hash-beta-1.2.0)
Up to date nightly-[HOST_TRIPLE] 1.3.0 (hash-nightly-2)

"#]]);
}
Expand All @@ -209,9 +209,9 @@ async fn check_updates_some() {
.await
.is_ok()
.with_stdout(snapbox::str![[r#"
stable-[HOST_TRIPLE] - update available: 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0)
beta-[HOST_TRIPLE] - update available: 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0)
nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2)
Update available stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0)
Update available beta-[HOST_TRIPLE] 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0)
Update available nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2)

"#]]);
}
Expand All @@ -234,7 +234,7 @@ async fn check_updates_self() {
.extend_redactions([("[TEST_VERSION]", test_version)])
.is_ok()
.with_stdout(snapbox::str![[r#"
rustup - Update available : [CURRENT_VERSION] -> [TEST_VERSION]
Update available rustup [CURRENT_VERSION] -> [TEST_VERSION]

"#]]);
}
Expand All @@ -256,7 +256,7 @@ async fn check_updates_self_no_change() {
.await
.is_err()
.with_stdout(snapbox::str![[r#"
rustup - Up to date : [CURRENT_VERSION]
Up to date rustup [CURRENT_VERSION]

"#]]);
}
Expand All @@ -276,9 +276,9 @@ async fn check_updates_with_update() {
.await
.is_err()
.with_stdout(snapbox::str![[r#"
stable-[HOST_TRIPLE] - up to date: 1.0.0 (hash-stable-1.0.0)
beta-[HOST_TRIPLE] - up to date: 1.1.0 (hash-beta-1.1.0)
nightly-[HOST_TRIPLE] - up to date: 1.2.0 (hash-nightly-1)
Up to date stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0)
Up to date beta-[HOST_TRIPLE] 1.1.0 (hash-beta-1.1.0)
Up to date nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1)

"#]]);
}
Expand All @@ -289,9 +289,9 @@ nightly-[HOST_TRIPLE] - up to date: 1.2.0 (hash-nightly-1)
.await
.is_ok()
.with_stdout(snapbox::str![[r#"
stable-[HOST_TRIPLE] - update available: 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0)
beta-[HOST_TRIPLE] - update available: 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0)
nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2)
Update available stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0)
Update available beta-[HOST_TRIPLE] 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0)
Update available nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2)

"#]]);
cx.config.expect(["rustup", "update", "beta"]).await.is_ok();
Expand All @@ -300,9 +300,9 @@ nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-
.await
.is_ok()
.with_stdout(snapbox::str![[r#"
stable-[HOST_TRIPLE] - update available: 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0)
beta-[HOST_TRIPLE] - up to date: 1.2.0 (hash-beta-1.2.0)
nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2)
Update available stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0)
Up to date beta-[HOST_TRIPLE] 1.2.0 (hash-beta-1.2.0)
Update available nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2)

"#]]);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading