Skip to content

Commit

Permalink
Improve error message if publish is false or empty list
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <[email protected]>
  • Loading branch information
Rustin170506 committed Oct 23, 2022
1 parent 071eeaf commit 3bbd5a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
let reg_name = publish_registry
.clone()
.unwrap_or_else(|| CRATES_IO_REGISTRY.to_string());
if !allowed_registries.contains(&reg_name) {
if allowed_registries.is_empty() {
bail!(
"`{}` cannot be published.\n\
`publish` is set to `false` or an empty list in Cargo.toml and prevents publishing.",
pkg.name(),
);
} else if !allowed_registries.contains(&reg_name) {
bail!(
"`{}` cannot be published.\n\
The registry `{}` is not listed in the `publish` value in Cargo.toml.",
Expand Down

0 comments on commit 3bbd5a5

Please sign in to comment.