bail!("crates cannot be published to crates.io with dependencies sourced from other\n\
registries either publish `{}` on crates.io or pull it into this repository\n\
and specify it with a path and version\n\
- (crate `{}` is pulled from {}", dep.name(), dep.name(), dep.source_id());
+ (crate `{}` is pulled from {})", dep.name(), dep.name(), dep.source_id());
}
} else {
bail!("crates cannot be published to crates.io with dependencies sourced from \
Some(vecstring.clone())
},
Some(VecStringOrBool::Bool(false)) => Some(vec![]),
- _ => None,
+ None | Some(VecStringOrBool::Bool(true)) => None,
};
let mut manifest = Manifest::new(summary,
targets,
.with_stderr_contains(" dependency (bar) specification is ambiguous. Only one of `git` or `registry` is allowed."));
}
+#[test]
+fn cannot_publish_to_crates_io_with_registry_dependency() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ cargo-features = ["alternative-registries"]
+ [project]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ [dependencies.bar]
+ version = "0.0.1"
+ registry = "alternative"
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .build();
+
+ Package::new("bar", "0.0.1").alternative(true).publish();
+
+ assert_that(p.cargo("publish").masquerade_as_nightly_cargo()
+ .arg("--index").arg(registry::registry().to_string()),
+ execs().with_status(101));
+}
+
#[test]
fn publish_with_registry_dependency() {
let p = project("foo")