From c2608423b6eec5eb91d0ffc861714c011ad3988b Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 26 Dec 2022 16:35:04 +0200 Subject: [PATCH] fix(cli): don't panic when a crate version couldn't be parsed (#5873) Co-authored-by: Lucas Fernandes Nogueira --- .changes/cli-info.md | 6 ++++++ tooling/cli/src/info.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/cli-info.md diff --git a/.changes/cli-info.md b/.changes/cli-info.md new file mode 100644 index 000000000000..e35cd900773e --- /dev/null +++ b/.changes/cli-info.md @@ -0,0 +1,6 @@ +--- +"cli.rs": "patch" +--- + +Fix `tauri info` panicking when parsing crates version on a newly created project without a `Cargo.lock` file. + diff --git a/tooling/cli/src/info.rs b/tooling/cli/src/info.rs index 37edc7224509..c637b6cae225 100644 --- a/tooling/cli/src/info.rs +++ b/tooling/cli/src/info.rs @@ -499,10 +499,10 @@ fn crate_version( let crate_version = found_crate_versions .into_iter() - .map(|v| semver::Version::parse(&v).unwrap()) + .map(|v| semver::Version::parse(&v).ok()) .max(); let suffix = match (crate_version, crate_latest_version(name)) { - (Some(version), Some(target_version)) => { + (Some(Some(version)), Some(target_version)) => { let target_version = semver::Version::parse(&target_version).unwrap(); if version < target_version { Some(format!(" (outdated, latest: {target_version})"))