From 78a04a5afd4ef2bfb5c518a0a257b8f252100ae8 Mon Sep 17 00:00:00 2001 From: Mathieu Kniewallner Date: Fri, 23 Aug 2024 01:10:29 +0200 Subject: [PATCH 1/2] feat(self-update): show old version in update message --- crates/uv/src/commands/self_update.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/uv/src/commands/self_update.rs b/crates/uv/src/commands/self_update.rs index c65e003c9b83..d57efec83850 100644 --- a/crates/uv/src/commands/self_update.rs +++ b/crates/uv/src/commands/self_update.rs @@ -74,14 +74,24 @@ pub(crate) async fn self_update(printer: Printer) -> Result { // available version of uv. match updater.run().await { Ok(Some(result)) => { + let version_information = if result.old_version.is_some() { + format!( + "from {} to {}", + format!("v{}", result.old_version.unwrap()).bold().white(), + format!("v{}", result.new_version).bold().white(), + ) + } else { + format!("to {}", format!("v{}", result.new_version).bold().white()) + }; + writeln!( printer.stderr(), "{}", format_args!( - "{}{} Upgraded uv to {}! {}", + "{}{} Upgraded uv {}! {}", "success".green().bold(), ":".bold(), - format!("v{}", result.new_version).bold().white(), + version_information, format!( "https://github.com/astral-sh/uv/releases/tag/{}", result.new_version_tag From 36b1c7557e75970fded0d2349ccd570af7d61902 Mon Sep 17 00:00:00 2001 From: Mathieu Kniewallner Date: Fri, 23 Aug 2024 03:05:57 +0200 Subject: [PATCH 2/2] refactor(self-update): pattern match to avoid unwrapping --- crates/uv/src/commands/self_update.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/uv/src/commands/self_update.rs b/crates/uv/src/commands/self_update.rs index d57efec83850..3c0c1ffc485c 100644 --- a/crates/uv/src/commands/self_update.rs +++ b/crates/uv/src/commands/self_update.rs @@ -74,10 +74,10 @@ pub(crate) async fn self_update(printer: Printer) -> Result { // available version of uv. match updater.run().await { Ok(Some(result)) => { - let version_information = if result.old_version.is_some() { + let version_information = if let Some(old_version) = result.old_version { format!( "from {} to {}", - format!("v{}", result.old_version.unwrap()).bold().white(), + format!("v{old_version}").bold().white(), format!("v{}", result.new_version).bold().white(), ) } else {