Skip to content

Commit

Permalink
Auto merge of #5616 - matklad:install-betas-from-git, r=alexcrichton
Browse files Browse the repository at this point in the history
Install pre-release versions by default for git deps

Recently we've fixed a bug where `cargo install foo` would install `foo 2.0-beta.1` instead of `foo 1.0`, but this behavior is wrong for git and path deps.
  • Loading branch information
bors committed Jun 27, 2018
2 parents ce455cd + 1c15c72 commit 90b5df8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
25 changes: 25 additions & 0 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 90b5df8

Please sign in to comment.