Skip to content

Commit

Permalink
Fix bug in --no-private flag on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 28, 2023
1 parent 4ff239e commit b8d6356
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Fix bug in `--no-private` flag on Windows.

## [0.2.3] - 2023-07-28

- Update `cargo_metadata` to 0.17.
Expand Down
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ mod cargo;
mod cli;
mod restore;

use std::env;
use std::{env, path::PathBuf};

use anyhow::{bail, Context as _, Result};
use camino::Utf8PathBuf;
use fs_err as fs;

use crate::{cargo::Workspace, cli::Args};
Expand Down Expand Up @@ -77,7 +76,7 @@ fn with(
if is_root {
bail!("--no-private is not supported yet with workspace with private root crate");
}
private_crates.push(manifest_path);
private_crates.push(manifest_path.canonicalize()?);
} else if is_root && no_private {
//
} else if no_dev_deps {
Expand Down Expand Up @@ -146,7 +145,7 @@ fn remove_dev_deps(doc: &mut toml_edit::Document) {
fn remove_private_crates(
doc: &mut toml_edit::Document,
metadata: &cargo_metadata::Metadata,
private_crates: &[&Utf8PathBuf],
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 @@ -158,7 +157,7 @@ fn remove_private_crates(
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.as_std_path() == manifest_path) {
if private_crates.iter().any(|p| *p == manifest_path) {
members.remove(i);
continue;
}
Expand Down

0 comments on commit b8d6356

Please sign in to comment.