Skip to content

Commit

Permalink
Use same-file crate instead of canonicalize
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 28, 2023
1 parent a492990 commit 1239baa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ anyhow = "1.0.47"
ctrlc = { version = "3.1.4", features = ["termination"] }
is-terminal = "0.4"
lexopt = "0.3"
same-file = "1.0.1"
serde_json = "1"
slab = "0.4.4"
termcolor = "1.1"
Expand Down
18 changes: 13 additions & 5 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub(crate) fn with(cx: &Context, f: impl FnOnce() -> Result<()>) -> Result<()> {
"--no-private is not supported yet with workspace with private root crate"
);
}
private_crates.push(manifest_path.canonicalize()?);
private_crates.push(manifest_path);
} else if is_root && no_private {
//
} else if no_dev_deps {
Expand Down Expand Up @@ -197,7 +197,7 @@ fn remove_dev_deps(doc: &mut toml_edit::Document) {
fn remove_private_crates(
doc: &mut toml_edit::Document,
metadata: &metadata::Metadata,
private_crates: &[PathBuf],
private_crates: &[&PathBuf],
) -> Result<()> {
let table = doc.as_table_mut();
if let Some(workspace) = table.get_mut("workspace").and_then(toml_edit::Item::as_table_like_mut)
Expand All @@ -207,9 +207,17 @@ fn remove_private_crates(
let mut i = 0;
while i < members.len() {
if let Some(member) = members.get(i).and_then(toml_edit::Value::as_str) {
let manifest_path =
metadata.workspace_root.join(member).join("Cargo.toml").canonicalize()?;
if private_crates.iter().any(|p| *p == manifest_path) {
let manifest_path = metadata.workspace_root.join(member).join("Cargo.toml");
if private_crates
.iter()
.find_map(|p| {
same_file::is_same_file(p, &manifest_path)
.map(|v| if v { Some(()) } else { None })
.transpose()
})
.transpose()?
.is_some()
{
members.remove(i);
continue;
}
Expand Down

0 comments on commit 1239baa

Please sign in to comment.