Skip to content

Commit

Permalink
Defer to cargo metadata to evaluate the workspace root (#660)
Browse files Browse the repository at this point in the history
Not a big deal, but I think we can just defer
  • Loading branch information
max-sixty authored Jan 4, 2025
1 parent 1d9ddea commit 60638c2
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions cargo-insta/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,6 @@ fn handle_target_args<'a>(
) -> Result<LocationInfo<'a>, Box<dyn Error>> {
let mut cmd = cargo_metadata::MetadataCommand::new();

// if a workspace root is provided we first check if it points to a
// `Cargo.toml`. If it does we instead treat it as manifest path. If both
// are provided we fail with an error.
match (
target_args.workspace_root.as_deref(),
target_args.manifest_path.as_deref(),
Expand All @@ -429,14 +426,7 @@ fn handle_target_args<'a>(
cmd.manifest_path(manifest);
}
(Some(root), None) => {
// TODO: should we do this ourselves? Probably fine, but are we
// adding anything by not just deferring to cargo?
let assumed_manifest = root.join("Cargo.toml");
if assumed_manifest.is_file() {
cmd.manifest_path(assumed_manifest);
} else {
cmd.current_dir(root);
}
cmd.current_dir(root);
}
(None, None) => {}
};
Expand Down

0 comments on commit 60638c2

Please sign in to comment.