@@ -2064,6 +2064,75 @@ fn git_install_reads_workspace_manifest() {
2064
2064
. run ( ) ;
2065
2065
}
2066
2066
2067
+ #[ cargo_test]
2068
+ fn git_install_the_same_bin_twice_with_different_rev ( ) {
2069
+ let project = git:: new ( "foo" , |project| {
2070
+ project
2071
+ . file (
2072
+ "Cargo.toml" ,
2073
+ r#"
2074
+ [workspace]
2075
+ members = ["bin1"]
2076
+ "# ,
2077
+ )
2078
+ . file ( "bin1/Cargo.toml" , & basic_manifest ( "bin1" , "0.1.0" ) )
2079
+ . file (
2080
+ "bin1/src/main.rs" ,
2081
+ r#"fn main() { println!("Hello, world!"); }"# ,
2082
+ )
2083
+ } ) ;
2084
+ let repository = git2:: Repository :: open ( & project. root ( ) ) . unwrap ( ) ;
2085
+ let first_rev = repository. revparse_single ( "HEAD" ) . unwrap ( ) . id ( ) . to_string ( ) ;
2086
+
2087
+ // Change the main.rs.
2088
+ fs:: write (
2089
+ project. root ( ) . join ( "bin1/src/main.rs" ) ,
2090
+ r#"fn main() { println!("Hello, world! 2"); }"# ,
2091
+ )
2092
+ . expect ( "failed to write file" ) ;
2093
+ git:: commit ( & repository) ;
2094
+ let second_rev = repository. revparse_single ( "HEAD" ) . unwrap ( ) . id ( ) . to_string ( ) ;
2095
+
2096
+ // Set up a temp target directory.
2097
+ let temp_dir = paths:: root ( ) . join ( "temp-target" ) ;
2098
+ cargo_process ( & format ! (
2099
+ "install --git {} --rev {} bin1 --target-dir {}" ,
2100
+ project. url( ) . to_string( ) ,
2101
+ second_rev,
2102
+ temp_dir. display( )
2103
+ ) )
2104
+ . with_stderr (
2105
+ "\
2106
+ [UPDATING] git repository [..]
2107
+ [INSTALLING] bin1 v0.1.0 [..]
2108
+ [COMPILING] bin1 v0.1.0 [..]
2109
+ [FINISHED] [..]
2110
+ [INSTALLING] [..]home/.cargo/bin/bin1[..]
2111
+ [INSTALLED] package `bin1 [..]
2112
+ [WARNING] be sure to add [..]
2113
+ " ,
2114
+ )
2115
+ . run ( ) ;
2116
+
2117
+ cargo_process ( & format ! (
2118
+ "install --git {} --rev {} bin1 --target-dir {}" ,
2119
+ project. url( ) . to_string( ) ,
2120
+ first_rev,
2121
+ temp_dir. display( )
2122
+ ) )
2123
+ . with_stderr (
2124
+ "\
2125
+ [UPDATING] git repository [..]
2126
+ [INSTALLING] bin1 v0.1.0 [..]
2127
+ [FINISHED] [..]
2128
+ [REPLACING] [..]home/.cargo/bin/bin1[..]
2129
+ [REPLACED] package `bin1 [..]
2130
+ [WARNING] be sure to add [..]
2131
+ " ,
2132
+ )
2133
+ . run ( ) ;
2134
+ }
2135
+
2067
2136
#[ cargo_test]
2068
2137
fn install_git_with_symlink_home ( ) {
2069
2138
// Ensure that `cargo install` with a git repo is OK when CARGO_HOME is a
0 commit comments