From cb6299aa10418e655e6e585b564190ad802ad535 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Mon, 19 Aug 2024 22:56:33 +0000 Subject: [PATCH] Enable `git_dependency_root` to work concurrently --- dylint/src/library_packages/cargo_cli/mod.rs | 88 ++++++++++++-------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/dylint/src/library_packages/cargo_cli/mod.rs b/dylint/src/library_packages/cargo_cli/mod.rs index 774ffdcc6..d787fb74d 100644 --- a/dylint/src/library_packages/cargo_cli/mod.rs +++ b/dylint/src/library_packages/cargo_cli/mod.rs @@ -136,46 +136,60 @@ fn git_dependency_root(url: &str, details: &TomlDetailedDependency) -> Result Ok(path), - (Err(err), true) => Err(err), - (Err(err), false) => Err(err).with_context(|| { - format!( - "fetching packages failed\nstdout: {:?}\nstderr: {:?}", - String::from_utf8(output.stdout).unwrap_or_default(), - dummy_dependency_free_suffix( - &dep_name, - &String::from_utf8(output.stderr).unwrap_or_default() - ) - ) - }), - }?; - - Ok(path.to_path_buf()) + ) { + Ok(path) => { + return Ok(path.to_path_buf()); + } + Err(error) => { + let s = if output.status.success() { + error.to_string() + } else { + format!( + "{:?}", + Result::::Err(error).with_context(|| { + format!( + "fetching packages failed\nstdout: {:?}\nstderr: {:?}", + String::from_utf8(output.stdout).unwrap_or_default(), + dummy_dependency_free_suffix( + &dep_name, + &String::from_utf8(output.stderr).unwrap_or_default() + ) + ) + }) + ) + }; + errors.push(s); + } + } + } + + Err(anyhow!("Could not find git dependency root: {errors:#?}")) } /// Creates a dummy dependency in a temporary directory, and returns the temporary directory if @@ -344,7 +358,7 @@ fn find_accessed_subdir<'a>( accessed .into_iter() .next() - .ok_or_else(|| anyhow!("Could not determined accessed subdirectory")) + .ok_or_else(|| anyhow!("Could not determine accessed subdirectory")) } fn for_each_subdir(