File tree Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -1171,6 +1171,74 @@ src/lib.rs
11711171 . run ( ) ;
11721172}
11731173
1174+ #[ cargo_test]
1175+ fn issue_13695_dirty_vcs_info ( ) {
1176+ let p = project ( )
1177+ . file (
1178+ "Cargo.toml" ,
1179+ r#"
1180+ [package]
1181+ name = "foo"
1182+ version = "0.1.0"
1183+ edition = "2015"
1184+ description = "foo"
1185+ license = "foo"
1186+ documentation = "foo"
1187+ "# ,
1188+ )
1189+ . file ( "src/lib.rs" , "" )
1190+ . build ( ) ;
1191+
1192+ let repo = git:: init ( & p. root ( ) ) ;
1193+ // Initial commit, with no files added.
1194+ git:: commit ( & repo) ;
1195+
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.
1213+ p. cargo ( "package --allow-dirty" ) . run ( ) ;
1214+
1215+ let f = File :: open ( & p. root ( ) . join ( "target/package/foo-0.1.0.crate" ) ) . unwrap ( ) ;
1216+ validate_crate_contents (
1217+ f,
1218+ "foo-0.1.0.crate" ,
1219+ & [
1220+ ".cargo_vcs_info.json" ,
1221+ "Cargo.toml" ,
1222+ "Cargo.toml.orig" ,
1223+ "src/lib.rs" ,
1224+ ] ,
1225+ & [ ] ,
1226+ ) ;
1227+
1228+ // Listing provides a consistent result.
1229+ p. cargo ( "package --list --allow-dirty" )
1230+ . with_stderr ( "" )
1231+ . with_stdout (
1232+ "\
1233+ .cargo_vcs_info.json
1234+ Cargo.toml
1235+ Cargo.toml.orig
1236+ src/lib.rs
1237+ " ,
1238+ )
1239+ . run ( ) ;
1240+ }
1241+
11741242#[ cargo_test]
11751243fn generated_manifest ( ) {
11761244 let registry = registry:: alt_init ( ) ;
You can’t perform that action at this time.
0 commit comments