mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
fix(publish): Report all unpublishable packages
I didn't extend this to multiple packages restricted to specific registries. It seems less likely to be a problem and more complex to gather and report. This was inspired by feedback left at #10948
This commit is contained in:
parent
a282233ae4
commit
1eafdb2656
@ -703,14 +703,17 @@ fn package_list(pkgs: impl IntoIterator<Item = PackageId>, final_sep: &str) -> S
|
||||
}
|
||||
|
||||
fn validate_registry(pkgs: &[&Package], reg_or_index: Option<&RegistryOrIndex>) -> CargoResult<()> {
|
||||
for pkg in pkgs {
|
||||
if pkg.publish() == &Some(Vec::new()) {
|
||||
bail!(
|
||||
"`{}` cannot be published.\n\
|
||||
`package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.",
|
||||
pkg.name(),
|
||||
);
|
||||
}
|
||||
let unpublishable = pkgs
|
||||
.iter()
|
||||
.filter(|pkg| pkg.publish() == &Some(Vec::new()))
|
||||
.map(|pkg| format!("`{}`", pkg.name()))
|
||||
.collect::<Vec<_>>();
|
||||
if !unpublishable.is_empty() {
|
||||
bail!(
|
||||
"{} cannot be published.\n\
|
||||
`package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.",
|
||||
unpublishable.join(", ")
|
||||
);
|
||||
}
|
||||
|
||||
let reg_name = match reg_or_index {
|
||||
|
@ -4105,7 +4105,7 @@ fn multiple_unpublishable_package() {
|
||||
.masquerade_as_nightly_cargo(&["package-workspace"])
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] `dep` cannot be published.
|
||||
[ERROR] `dep`, `main` cannot be published.
|
||||
`package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
|
||||
|
||||
"#]])
|
||||
|
Loading…
x
Reference in New Issue
Block a user