Skip to content

Commit

Permalink
Auto merge of #14488 - tweag:package-filter-current, r=epage
Browse files Browse the repository at this point in the history
Don't automatically include the current crate when packaging

This replicates some of the changes in #10677 while packaging. It was split off from #14433
  • Loading branch information
bors committed Sep 3, 2024
2 parents ee6f1c8 + 4110b84 commit 2807645
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult<Vec<Fi
spec.query(member_ids)?;
}
}
let pkgs = ws.members_with_features(specs, &opts.cli_features)?;
let mut pkgs = ws.members_with_features(specs, &opts.cli_features)?;

// In `members_with_features_old`, it will add "current" package (determined by the cwd)
// So we need filter
pkgs.retain(|(pkg, _feats)| specs.iter().any(|spec| spec.matches(pkg.package_id())));

if ws
.lock_root()
Expand Down
41 changes: 41 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6500,3 +6500,44 @@ Caused by:
"#]])
.run();
}

#[cargo_test]
fn in_package_workspace_with_members_with_features_old() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[workspace]
members = ["li"]
"#,
)
.file("src/main.rs", "fn main() {}")
.file(
"li/Cargo.toml",
r#"
[package]
name = "li"
version = "0.0.1"
edition = "2015"
rust-version = "1.69"
description = "li"
license = "MIT"
"#,
)
.file("li/src/main.rs", "fn main() {}")
.build();

p.cargo("package -p li --no-verify")
.with_stderr_data(str![[r#"
[WARNING] manifest has no documentation, homepage or repository.
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
[PACKAGING] li v0.0.1 ([ROOT]/foo/li)
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
"#]])
.run();
}

0 comments on commit 2807645

Please sign in to comment.