]> git.proxmox.com Git - cargo.git/commitdiff
Install pre-release versions by default for git deps
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 7 Jun 2018 19:33:03 +0000 (22:33 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 11 Jun 2018 18:47:09 +0000 (21:47 +0300)
closes #5627

src/cargo/ops/cargo_install.rs
tests/testsuite/install.rs

index 9516aac0917627029f880d21f4fa484a3fff4f7f..201a7203c7d35efcd998171200d4f3dc2d44f8d6 100644 (file)
@@ -480,9 +480,16 @@ where
                 None => None,
             };
             let vers = vers.as_ref().map(|s| &**s);
+            let vers_spec = if vers.is_none() && source.source_id().is_registry() {
+                // Avoid pre-release versions from crate.io
+                // unless explicitly asked for
+                Some("*")
+            } else {
+                vers
+            };
             let dep = Dependency::parse_no_deprecated(
                 name,
-                Some(vers.unwrap_or("*")),
+                vers_spec,
                 source.source_id(),
             )?;
             let deps = source.query_vec(&dep)?;
index 6c24e17f0c2a197dec7676a74ef64636710d4644..0559c5704405257f38a983ca2c01fbab77cd39e6 100644 (file)
@@ -138,6 +138,31 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina
     assert_that(cargo_home(), has_installed_exe("foo"));
 }
 
+#[test]
+fn installs_beta_version_by_explicit_name_from_git() {
+    let p = git::repo(&paths::root().join("foo"))
+        .file(
+            "Cargo.toml",
+            r#"
+            [package]
+            name = "foo"
+            version = "0.3.0-beta.1"
+            authors = []
+        "#,
+        )
+        .file("src/main.rs", "fn main() {}")
+        .build();
+
+    assert_that(
+        cargo_process("install")
+            .arg("--git")
+            .arg(p.url().to_string())
+            .arg("foo"),
+        execs().with_status(0),
+    );
+    assert_that(cargo_home(), has_installed_exe("foo"));
+}
+
 #[test]
 fn missing() {
     pkg("foo", "0.0.1");