File tree 2 files changed +33
-1
lines changed 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -480,9 +480,16 @@ where
480
480
None => None ,
481
481
} ;
482
482
let vers = vers. as_ref ( ) . map ( |s| & * * s) ;
483
+ let vers_spec = if vers. is_none ( ) && source. source_id ( ) . is_registry ( ) {
484
+ // Avoid pre-release versions from crate.io
485
+ // unless explicitly asked for
486
+ Some ( "*" )
487
+ } else {
488
+ vers
489
+ } ;
483
490
let dep = Dependency :: parse_no_deprecated (
484
491
name,
485
- Some ( vers . unwrap_or ( "*" ) ) ,
492
+ vers_spec ,
486
493
source. source_id ( ) ,
487
494
) ?;
488
495
let deps = source. query_vec ( & dep) ?;
Original file line number Diff line number Diff line change @@ -138,6 +138,31 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina
138
138
assert_that ( cargo_home ( ) , has_installed_exe ( "foo" ) ) ;
139
139
}
140
140
141
+ #[ test]
142
+ fn installs_beta_version_by_explicit_name_from_git ( ) {
143
+ let p = git:: repo ( & paths:: root ( ) . join ( "foo" ) )
144
+ . file (
145
+ "Cargo.toml" ,
146
+ r#"
147
+ [package]
148
+ name = "foo"
149
+ version = "0.3.0-beta.1"
150
+ authors = []
151
+ "# ,
152
+ )
153
+ . file ( "src/main.rs" , "fn main() {}" )
154
+ . build ( ) ;
155
+
156
+ assert_that (
157
+ cargo_process ( "install" )
158
+ . arg ( "--git" )
159
+ . arg ( p. url ( ) . to_string ( ) )
160
+ . arg ( "foo" ) ,
161
+ execs ( ) . with_status ( 0 ) ,
162
+ ) ;
163
+ assert_that ( cargo_home ( ) , has_installed_exe ( "foo" ) ) ;
164
+ }
165
+
141
166
#[ test]
142
167
fn missing ( ) {
143
168
pkg ( "foo" , "0.0.1" ) ;
You can’t perform that action at this time.
0 commit comments