@@ -189,7 +189,8 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
189
189
let vcs_contents = format ! (
190
190
r#"{{
191
191
"git": {{
192
- "sha1": "{}"
192
+ "sha1": "{}",
193
+ "dirty": false
193
194
}},
194
195
"path_in_vcs": ""
195
196
}}
@@ -230,7 +231,8 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
230
231
let vcs_contents = format ! (
231
232
r#"{{
232
233
"git": {{
233
- "sha1": "{}"
234
+ "sha1": "{}",
235
+ "dirty": false
234
236
}},
235
237
"path_in_vcs": "a/a"
236
238
}}
@@ -1174,7 +1176,7 @@ src/lib.rs
1174
1176
}
1175
1177
1176
1178
#[ cargo_test]
1177
- fn issue_13695_dirty_vcs_info ( ) {
1179
+ fn issue_13695_allow_dirty_vcs_info ( ) {
1178
1180
let p = project ( )
1179
1181
. file (
1180
1182
"Cargo.toml" ,
@@ -1195,23 +1197,7 @@ fn issue_13695_dirty_vcs_info() {
1195
1197
// Initial commit, with no files added.
1196
1198
git:: commit ( & repo) ;
1197
1199
1198
- // Fail because worktree is dirty.
1199
- p. cargo ( "package" )
1200
- . with_status ( 101 )
1201
- . with_stderr_contains (
1202
- "[ERROR] 2 files in the working directory contain changes that were not yet committed into git:" ,
1203
- )
1204
- . run ( ) ;
1205
-
1206
- // Listing fails too.
1207
- p. cargo ( "package --list" )
1208
- . with_status ( 101 )
1209
- . with_stderr_contains (
1210
- "[ERROR] 2 files in the working directory contain changes that were not yet committed into git:" ,
1211
- )
1212
- . run ( ) ;
1213
-
1214
- // Allowing a dirty worktree results in the vcs file being included.
1200
+ // Allowing a dirty worktree results in the vcs file still being included.
1215
1201
p. cargo ( "package --allow-dirty" ) . run ( ) ;
1216
1202
1217
1203
let f = File :: open ( & p. root ( ) . join ( "target/package/foo-0.1.0.crate" ) ) . unwrap ( ) ;
@@ -1224,7 +1210,16 @@ fn issue_13695_dirty_vcs_info() {
1224
1210
"Cargo.toml.orig" ,
1225
1211
"src/lib.rs" ,
1226
1212
] ,
1227
- & [ ] ,
1213
+ & [ (
1214
+ ".cargo_vcs_info.json" ,
1215
+ r#"{
1216
+ "git": {
1217
+ "sha1": "[..]",
1218
+ "dirty": true
1219
+ },
1220
+ "path_in_vcs": ""
1221
+ }"# ,
1222
+ ) ] ,
1228
1223
) ;
1229
1224
1230
1225
// Listing provides a consistent result.
@@ -1241,6 +1236,51 @@ src/lib.rs
1241
1236
. run ( ) ;
1242
1237
}
1243
1238
1239
+ #[ cargo_test]
1240
+ fn issue_13695_allowing_dirty_vcs_info_but_clean ( ) {
1241
+ let p = project ( ) . build ( ) ;
1242
+ let _ = git:: repo ( & paths:: root ( ) . join ( "foo" ) )
1243
+ . file (
1244
+ "Cargo.toml" ,
1245
+ r#"
1246
+ [package]
1247
+ name = "foo"
1248
+ version = "0.1.0"
1249
+ edition = "2015"
1250
+ description = "foo"
1251
+ license = "foo"
1252
+ documentation = "foo"
1253
+ "# ,
1254
+ )
1255
+ . file ( "src/lib.rs" , "" )
1256
+ . build ( ) ;
1257
+
1258
+ // Allowing a dirty worktree despite it being clean.
1259
+ p. cargo ( "package --allow-dirty" ) . run ( ) ;
1260
+
1261
+ let f = File :: open ( & p. root ( ) . join ( "target/package/foo-0.1.0.crate" ) ) . unwrap ( ) ;
1262
+ validate_crate_contents (
1263
+ f,
1264
+ "foo-0.1.0.crate" ,
1265
+ & [
1266
+ ".cargo_vcs_info.json" ,
1267
+ "Cargo.toml" ,
1268
+ "Cargo.toml.orig" ,
1269
+ "src/lib.rs" ,
1270
+ ] ,
1271
+ & [ (
1272
+ ".cargo_vcs_info.json" ,
1273
+ r#"{
1274
+ "git": {
1275
+ "sha1": "[..]",
1276
+ "dirty": false
1277
+ },
1278
+ "path_in_vcs": ""
1279
+ }"# ,
1280
+ ) ] ,
1281
+ ) ;
1282
+ }
1283
+
1244
1284
#[ cargo_test]
1245
1285
fn generated_manifest ( ) {
1246
1286
let registry = registry:: alt_init ( ) ;
0 commit comments