From 950e95b8c2793bef9a9faf87ec5e2545d1c83815 Mon Sep 17 00:00:00 2001 From: Ricky Date: Thu, 20 Aug 2020 18:37:09 -0400 Subject: [PATCH] Fixed unwrap error when checking for VersionReq and using a git repository as dependency --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cargo_ops/temp_project.rs | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7d2ae6..4d897a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "cargo-outdated" -version = "0.9.11" +version = "0.9.12" dependencies = [ "anyhow", "cargo", diff --git a/Cargo.toml b/Cargo.toml index 33d5d59..1b06568 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-outdated" -version = "0.9.11" +version = "0.9.12" authors = [ "Kevin K. ", "Frederick Z. ", diff --git a/src/cargo_ops/temp_project.rs b/src/cargo_ops/temp_project.rs index 7089142..3a3fbdf 100644 --- a/src/cargo_ops/temp_project.rs +++ b/src/cargo_ops/temp_project.rs @@ -374,7 +374,16 @@ impl<'tmp> TempProject<'tmp> { } }) .unwrap_or_else(|| { - self.warn(format!("cannot compare {} crate version found in toml {} with crates.io latest {}", name, version_req.as_ref().unwrap(), query_result[0].version())).unwrap(); + + // If the version_req cannot be found use the version + // this happens when we use a git repository as a dependency, without specifying + // the version in Cargo.toml, preventing us from needing an unwrap below in the warn + let ver_req = match version_req { + Some(v_r) => format!("{}", v_r), + None => format!("{}", version), + }; + + self.warn(format!("cannot compare {} crate version found in toml {} with crates.io latest {}", name, ver_req, query_result[0].version())).unwrap(); //this returns the latest version &query_result[0] });