Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Nov 11, 2024
1 parent 2cb2377 commit 0d10ab0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
23 changes: 10 additions & 13 deletions src/cm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,16 @@ pub struct Metadata {
impl Metadata {
/// Get the workspace's root package of this metadata instance.
pub fn root_package(&self) -> Option<&Package> {
match &self.resolve {
Some(resolve) => {
// if dependencies are resolved, use Cargo's answer
let root = resolve.root.as_ref()?;
self.packages.iter().find(|pkg| &pkg.id == root)
}
None => {
// if dependencies aren't resolved, check for a root package manually
let root_manifest_path = self.workspace_root.join("Cargo.toml");
self.packages
.iter()
.find(|pkg| pkg.manifest_path == root_manifest_path)
}
if let Some(resolve) = &self.resolve {
// if dependencies are resolved, use Cargo's answer
let root = resolve.root.as_ref()?;
self.packages.iter().find(|pkg| &pkg.id == root)
} else {
// if dependencies aren't resolved, check for a root package manually
let root_manifest_path = self.workspace_root.join("Cargo.toml");
self.packages
.iter()
.find(|pkg| pkg.manifest_path == root_manifest_path)
}
}

Expand Down
5 changes: 1 addition & 4 deletions tests/exclude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ fn excludes_workspace_member() {
#[test]
fn includes_by_path() {
let mut kb = krates::Builder::new();
kb.include_workspace_crates(&[
//"/home/jake/code/krates/tests/ws/b",
"/home/jake/code/krates/tests/ws/c",
]);
kb.include_workspace_crates(["/home/jake/code/krates/tests/ws/c"]);

let grafs = build("all-features.json", kb).unwrap();

Expand Down

0 comments on commit 0d10ab0

Please sign in to comment.