Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(self-update): show old version in update message #6473

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions crates/uv/src/commands/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,24 @@ pub(crate) async fn self_update(printer: Printer) -> Result<ExitStatus> {
// available version of uv.
match updater.run().await {
Ok(Some(result)) => {
let version_information = if result.old_version.is_some() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use let with a pattern to avoid unwrapping, e.g., if let Some(old_version) = result.old_version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know (or forgot?) that it was possible to use that while defining a variable, really nice, thanks!

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
Expand Down
Loading