File tree 1 file changed +62
-0
lines changed
1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -1169,6 +1169,68 @@ src/lib.rs
1169
1169
. run ( ) ;
1170
1170
}
1171
1171
1172
+ #[ cargo_test]
1173
+ fn issue_13695_dirty_vcs_info ( ) {
1174
+ let p = project ( )
1175
+ . file (
1176
+ "Cargo.toml" ,
1177
+ r#"
1178
+ [package]
1179
+ name = "foo"
1180
+ version = "0.1.0"
1181
+ edition = "2015"
1182
+ description = "foo"
1183
+ license = "foo"
1184
+ documentation = "foo"
1185
+ "# ,
1186
+ )
1187
+ . file ( "src/lib.rs" , "" )
1188
+ . build ( ) ;
1189
+
1190
+ let repo = git:: init ( & p. root ( ) ) ;
1191
+ // Initial commit, with no files added.
1192
+ git:: commit ( & repo) ;
1193
+
1194
+ // Fail because worktree is dirty.
1195
+ p. cargo ( "package" )
1196
+ . with_status ( 101 )
1197
+ . with_stderr_contains (
1198
+ "[ERROR] 2 files in the working directory contain changes that were not yet committed into git:" ,
1199
+ )
1200
+ . run ( ) ;
1201
+
1202
+ // Listing fails too.
1203
+ p. cargo ( "package --list" )
1204
+ . with_status ( 101 )
1205
+ . with_stderr_contains (
1206
+ "[ERROR] 2 files in the working directory contain changes that were not yet committed into git:" ,
1207
+ )
1208
+ . run ( ) ;
1209
+
1210
+ // Allowing a dirty worktree results in the vcs file not being included.
1211
+ p. cargo ( "package --allow-dirty" ) . run ( ) ;
1212
+
1213
+ let f = File :: open ( & p. root ( ) . join ( "target/package/foo-0.1.0.crate" ) ) . unwrap ( ) ;
1214
+ validate_crate_contents (
1215
+ f,
1216
+ "foo-0.1.0.crate" ,
1217
+ & [ "Cargo.toml" , "Cargo.toml.orig" , "src/lib.rs" ] ,
1218
+ & [ ] ,
1219
+ ) ;
1220
+
1221
+ // Listing provides a consistent result.
1222
+ p. cargo ( "package --list --allow-dirty" )
1223
+ . with_stderr ( "" )
1224
+ . with_stdout (
1225
+ "\
1226
+ Cargo.toml
1227
+ Cargo.toml.orig
1228
+ src/lib.rs
1229
+ " ,
1230
+ )
1231
+ . run ( ) ;
1232
+ }
1233
+
1172
1234
#[ cargo_test]
1173
1235
fn generated_manifest ( ) {
1174
1236
let registry = registry:: alt_init ( ) ;
You can’t perform that action at this time.
0 commit comments