@@ -187,7 +187,8 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
187187 let vcs_contents = format ! (
188188 r#"{{
189189 "git": {{
190- "sha1": "{}"
190+ "sha1": "{}",
191+ "dirty": false
191192 }},
192193 "path_in_vcs": ""
193194}}
@@ -228,7 +229,8 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
228229 let vcs_contents = format ! (
229230 r#"{{
230231 "git": {{
231- "sha1": "{}"
232+ "sha1": "{}",
233+ "dirty": false
232234 }},
233235 "path_in_vcs": "a/a"
234236}}
@@ -1172,7 +1174,7 @@ src/lib.rs
11721174}
11731175
11741176#[ cargo_test]
1175- fn issue_13695_dirty_vcs_info ( ) {
1177+ fn issue_13695_allow_dirty_vcs_info ( ) {
11761178 let p = project ( )
11771179 . file (
11781180 "Cargo.toml" ,
@@ -1193,23 +1195,7 @@ fn issue_13695_dirty_vcs_info() {
11931195 // Initial commit, with no files added.
11941196 git:: commit ( & repo) ;
11951197
1196- // Fail because worktree is dirty.
1197- p. cargo ( "package" )
1198- . with_status ( 101 )
1199- . with_stderr_contains (
1200- "[ERROR] 2 files in the working directory contain changes that were not yet committed into git:" ,
1201- )
1202- . run ( ) ;
1203-
1204- // Listing fails too.
1205- p. cargo ( "package --list" )
1206- . with_status ( 101 )
1207- . with_stderr_contains (
1208- "[ERROR] 2 files in the working directory contain changes that were not yet committed into git:" ,
1209- )
1210- . run ( ) ;
1211-
1212- // Allowing a dirty worktree results in the vcs file being included.
1198+ // Allowing a dirty worktree results in the vcs file still being included.
12131199 p. cargo ( "package --allow-dirty" ) . run ( ) ;
12141200
12151201 let f = File :: open ( & p. root ( ) . join ( "target/package/foo-0.1.0.crate" ) ) . unwrap ( ) ;
@@ -1222,7 +1208,16 @@ fn issue_13695_dirty_vcs_info() {
12221208 "Cargo.toml.orig" ,
12231209 "src/lib.rs" ,
12241210 ] ,
1225- & [ ] ,
1211+ & [ (
1212+ ".cargo_vcs_info.json" ,
1213+ r#"{
1214+ "git": {
1215+ "sha1": "[..]",
1216+ "dirty": true
1217+ },
1218+ "path_in_vcs": ""
1219+ }"# ,
1220+ ) ] ,
12261221 ) ;
12271222
12281223 // Listing provides a consistent result.
@@ -1239,6 +1234,51 @@ src/lib.rs
12391234 . run ( ) ;
12401235}
12411236
1237+ #[ cargo_test]
1238+ fn issue_13695_allowing_dirty_vcs_info_but_clean ( ) {
1239+ let p = project ( ) . build ( ) ;
1240+ let _ = git:: repo ( & paths:: root ( ) . join ( "foo" ) )
1241+ . file (
1242+ "Cargo.toml" ,
1243+ r#"
1244+ [package]
1245+ name = "foo"
1246+ version = "0.1.0"
1247+ edition = "2015"
1248+ description = "foo"
1249+ license = "foo"
1250+ documentation = "foo"
1251+ "# ,
1252+ )
1253+ . file ( "src/lib.rs" , "" )
1254+ . build ( ) ;
1255+
1256+ // Allowing a dirty worktree despite it being clean.
1257+ p. cargo ( "package --allow-dirty" ) . run ( ) ;
1258+
1259+ let f = File :: open ( & p. root ( ) . join ( "target/package/foo-0.1.0.crate" ) ) . unwrap ( ) ;
1260+ validate_crate_contents (
1261+ f,
1262+ "foo-0.1.0.crate" ,
1263+ & [
1264+ ".cargo_vcs_info.json" ,
1265+ "Cargo.toml" ,
1266+ "Cargo.toml.orig" ,
1267+ "src/lib.rs" ,
1268+ ] ,
1269+ & [ (
1270+ ".cargo_vcs_info.json" ,
1271+ r#"{
1272+ "git": {
1273+ "sha1": "[..]",
1274+ "dirty": false
1275+ },
1276+ "path_in_vcs": ""
1277+ }"# ,
1278+ ) ] ,
1279+ ) ;
1280+ }
1281+
12421282#[ cargo_test]
12431283fn generated_manifest ( ) {
12441284 let registry = registry:: alt_init ( ) ;
0 commit comments