From 83b2285e2a1f9d03456264f1c71b88cbbaf4f1a7 Mon Sep 17 00:00:00 2001 From: Ricky Date: Mon, 4 May 2020 08:43:03 -0400 Subject: [PATCH] Removed the always matching blank string for the CARGO_HOME variable. Updated the code from issue #219 and added comments explaining what why it is necessary to not crawl the CARGO_HOME for Cargo.toml files. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cargo_ops/temp_project.rs | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad744f9..cc806e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "cargo-outdated" -version = "0.9.9" +version = "0.9.10" dependencies = [ "anyhow", "cargo", diff --git a/Cargo.toml b/Cargo.toml index 85893f8..2a2d0dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-outdated" -version = "0.9.9" +version = "0.9.10" authors = [ "Kevin K. ", "Frederick Z. ", diff --git a/src/cargo_ops/temp_project.rs b/src/cargo_ops/temp_project.rs index 24ccf06..e147789 100644 --- a/src/cargo_ops/temp_project.rs +++ b/src/cargo_ops/temp_project.rs @@ -654,13 +654,17 @@ fn manifest_paths(elab: &ElaborateWorkspace<'_>) -> CargoResult> { visited.insert(pkg_id); let pkg = &elab.pkgs[&pkg_id]; let pkg_path = pkg.root().to_string_lossy(); + + // Checking if there's a CARGO_HOME set and that it is not an empty string let cargo_home_path = match std::env::var_os("CARGO_HOME") { - Some(path) => path.into_string().expect("Error getting string from OsString"), - None => "".to_string(), + Some(path) if !path.is_empty() => Some(path.into_string().expect("Error getting string from OsString")), + _ => None, }; + // If there is a CARGO_HOME make sure we do not crawl the registry for more Cargo.toml files + // Otherwise add all Cargo.toml files to the manifest paths if pkg_path.starts_with(workspace_path) { - if !pkg_path.starts_with(&cargo_home_path){ + if cargo_home_path.is_none() || !pkg_path.starts_with(&cargo_home_path.expect("Error extracting CARGO_HOME string")) { manifest_paths.push(pkg.manifest_path().to_owned()); } }