Don't install pre-releases by default
authorAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 2 May 2018 22:26:48 +0000 (01:26 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 2 May 2018 22:32:06 +0000 (01:32 +0300)
src/cargo/ops/cargo_install.rs
tests/testsuite/install.rs
tests/testsuite/patch.rs

index a793826cb6edb04998e13d36f61f846ad80eccf7..87fd147035737810d48687e2a65363b44d8e4345 100644 (file)
@@ -475,7 +475,11 @@ where
                 None => None,
             };
             let vers = vers.as_ref().map(|s| &**s);
-            let dep = Dependency::parse_no_deprecated(name, vers, source.source_id())?;
+            let dep = Dependency::parse_no_deprecated(
+                name,
+                Some(vers.unwrap_or("*")),
+                source.source_id(),
+            )?;
             let deps = source.query_vec(&dep)?;
             match deps.iter().map(|p| p.package_id()).max() {
                 Some(pkgid) => {
index 738b16f6a4b6c89864ddf7a1a3611c9d9a625a40..d3a18999d96d9a76f6da85b4385785b6ebaa1284 100644 (file)
@@ -113,17 +113,20 @@ error: some crates failed to install
 
 #[test]
 fn pick_max_version() {
-    pkg("foo", "0.0.1");
-    pkg("foo", "0.0.2");
+    pkg("foo", "0.1.0");
+    pkg("foo", "0.2.0");
+    pkg("foo", "0.2.1");
+    pkg("foo", "0.2.1-pre.1");
+    pkg("foo", "0.3.0-pre.2");
 
     assert_that(
         cargo_process("install").arg("foo"),
         execs().with_status(0).with_stderr(&format!(
             "\
 [UPDATING] registry `[..]`
-[DOWNLOADING] foo v0.0.2 (registry [..])
-[INSTALLING] foo v0.0.2
-[COMPILING] foo v0.0.2
+[DOWNLOADING] foo v0.2.1 (registry [..])
+[INSTALLING] foo v0.2.1
+[COMPILING] foo v0.2.1
 [FINISHED] release [optimized] target(s) in [..]
 [INSTALLING] {home}[..]bin[..]foo[..]
 warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
index 2e47ba84f08b64f9b7c0acf9f5406e864ab60d82..f30f19e098fbfa50a3da2b9d55ff01fa57ff9f38 100644 (file)
@@ -1109,3 +1109,52 @@ fn patch_depends_on_another_patch() {
         execs().with_status(0).with_stderr("[FINISHED] [..]"),
     );
 }
+
+#[test]
+fn replace_prerelease() {
+    Package::new("bar", "1.1.0-pre.1").publish();
+    let p = project("foo")
+        .file(
+            "Cargo.toml",
+            r#"
+            [workspace]
+            members = ["foo"]
+
+            [patch.crates-io]
+            bar = { path = "./bar" }
+        "#,
+        )
+        .file(
+            "foo/Cargo.toml",
+            r#"
+            [project]
+            name = "foo"
+            version = "0.5.0"
+            authors = []
+
+            [dependencies]
+            bar = "1.1.0-pre.1"
+        "#,
+        )
+        .file(
+            "foo/src/main.rs",
+            "
+            extern crate bar;
+            fn main() { bar::bar() }
+        ",
+        )
+        .file(
+            "bar/Cargo.toml",
+            r#"
+            [project]
+            name = "bar"
+            version = "1.1.0-pre.1"
+            authors = []
+            [workspace]
+        "#,
+        )
+        .file("bar/src/lib.rs", "pub fn bar() {}")
+        .build();
+
+    assert_that(p.cargo("build"), execs().with_status(0));
+}