Code review markups.
authorChris Swindle <christopher.swindle@metaswitch.com>
Mon, 6 Nov 2017 20:37:40 +0000 (20:37 +0000)
committerChris Swindle <christopher.swindle@metaswitch.com>
Mon, 6 Nov 2017 20:37:40 +0000 (20:37 +0000)
src/cargo/ops/registry.rs
src/cargo/util/toml/mod.rs
tests/alt-registry.rs

index 4f841d06ff6497627c9af7f6031b0458a82dc6d0..eef46da9e20cd28107a8af0b191668837ce02f67 100644 (file)
@@ -96,7 +96,7 @@ fn verify_dependencies(pkg: &Package, registry_src: &SourceId)
                     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 \
index 21fb27de952f2ba40b2d53f1280a5007aa242fdf..a2b33bfb1964d554cb23aa9113f0bab0a02af01f 100644 (file)
@@ -701,7 +701,7 @@ impl TomlManifest {
                 Some(vecstring.clone())
             },
             Some(VecStringOrBool::Bool(false)) => Some(vec![]),
-            _ => None,
+            None | Some(VecStringOrBool::Bool(true)) => None,
         };
         let mut manifest = Manifest::new(summary,
                                          targets,
index 45ef2153529a67dba0a1ec5bad637653bedba8ed..52e1842c42b42faf3ee3881c3819ddf837ac6c7c 100644 (file)
@@ -192,6 +192,29 @@ fn registry_incompatible_with_git() {
                 .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")