Skip to content

Commit

Permalink
fix: Don't add the new package to workspace.members if there is no ex…
Browse files Browse the repository at this point in the history
…isting workspace in Cargo.toml.
  • Loading branch information
linyihai committed Feb 2, 2024
1 parent 627b2ed commit 4474dc2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::io::{BufRead, BufReader, ErrorKind};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{fmt, slice};
use toml_edit::{Array, Value};
use toml_edit::Value;

#[derive(Clone, Copy, Debug, PartialEq)]
pub enum VersionControl {
Expand Down Expand Up @@ -992,11 +992,6 @@ fn update_manifest_with_new_member(
if was_sorted {
members.sort_by(|lhs, rhs| lhs.as_str().cmp(&rhs.as_str()));
}
} else {
let mut array = Array::new();
array.push(display_path);

workspace_document["workspace"]["members"] = toml_edit::value(array);
}

write_atomic(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
workspace = { members = ["bar"] }
[package]
name = "foo"
version = "0.1.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_new/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod add_lib_into_non_workspace;
mod add_members_to_workspace_format_previous_items;
mod add_members_to_workspace_format_sorted;
mod add_members_to_workspace_with_absolute_package_path;
Expand All @@ -12,4 +13,3 @@ mod inherit_workspace_package_table_with_edition;
mod inherit_workspace_package_table_with_registry;
mod inherit_workspace_package_table_without_version;
mod not_inherit_workspace_package_table_if_not_members;
mod add_lib_into_non_workspace;

0 comments on commit 4474dc2

Please sign in to comment.