Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip clean up profile.release.package."*" #12624

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/bin/cargo/commands/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
//
// Example tables:
// - profile.dev.package.foo
// - profile.release.package."*"
// - profile.release.package."foo:2.1.0"
if let Some(toml_edit::Item::Table(profile_section_table)) = manifest.get_mut("profile") {
profile_section_table.set_implicit(true);
Expand All @@ -231,8 +230,14 @@ fn gc_workspace(workspace: &Workspace<'_>) -> CargoResult<()> {
package_table.set_implicit(true);

for (key, item) in package_table.iter_mut() {
let key = key.get();
Rustin170506 marked this conversation as resolved.
Show resolved Hide resolved
// Skip globs. Can't do anything with them.
// For example, profile.release.package."*".
if crate::util::restricted_names::is_glob_pattern(key) {
continue;
}
if !spec_has_match(
&PackageIdSpec::parse(key.get())?,
&PackageIdSpec::parse(key)?,
&dependencies,
workspace.config(),
)? {
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod optional_dep_feature;
mod optional_feature;
mod package;
mod remove_basic;
mod skip_gc_glob_profile;
mod target;
mod target_build;
mod target_dev;
Expand Down
13 changes: 13 additions & 0 deletions tests/testsuite/cargo_remove/skip_gc_glob_profile/in/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "cargo-remove-test-fixture"
version = "0.1.0"

[[bin]]
name = "main"
path = "src/main.rs"

[dependencies]
toml = "0.1"

[profile.dev.package."*"]
opt-level = 3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/skip_gc_glob_profile/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

#[cargo_test]
fn case() {
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("remove")
.args(["toml"])
.current_dir(cwd)
.assert()
.success()
.stdout_matches_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));

assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
}
10 changes: 10 additions & 0 deletions tests/testsuite/cargo_remove/skip_gc_glob_profile/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "cargo-remove-test-fixture"
version = "0.1.0"

[[bin]]
name = "main"
path = "src/main.rs"

[profile.dev.package."*"]
opt-level = 3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removing toml from dependencies
Empty file.