From 7edd78c7974ec2a46198ea14dcefcb7d823350d9 Mon Sep 17 00:00:00 2001 From: Mathieu Kniewallner Date: Fri, 23 Aug 2024 14:55:47 +0200 Subject: [PATCH] feat(self-update): show old version in update message (#6473) ## Summary Indicate the previous version from which uv was upgraded when running `uv self update`. Thought that it could be useful in some situations to have a trace of the previous version that was installed. ## Test Plan Did not find a way to test this, since this heavily relies on being able to use the installation script and the ability to publish artifacts for a specific tag. --- 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 c65e003c9..3c0c1ffc4 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 let Some(old_version) = result.old_version { + format!( + "from {} to {}", + format!("v{old_version}").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