1+ use std:: fs:: File ;
2+
3+ use git2;
4+
15use support:: git;
26use support:: { execs, project} ;
37use support:: { is_nightly, ChannelChanger } ;
4- use git2;
58use support:: hamcrest:: assert_that;
69
710#[ test]
@@ -966,7 +969,14 @@ fn warns_about_dirty_working_directory() {
966969 )
967970 . build ( ) ;
968971
969- git2:: Repository :: init ( & p. root ( ) ) . unwrap ( ) ;
972+ let repo = git2:: Repository :: init ( & p. root ( ) ) . unwrap ( ) ;
973+ let mut cfg = t ! ( repo. config( ) ) ;
974+ t ! ( cfg
. set_str
( "user.email" , "[email protected] " ) ) ; 975+ t ! ( cfg. set_str( "user.name" , "Foo Bar" ) ) ;
976+ drop ( cfg) ;
977+ git:: add ( & repo) ;
978+ git:: commit ( & repo) ;
979+ File :: create ( p. root ( ) . join ( "src/lib.rs" ) ) . unwrap ( ) ;
970980
971981 assert_that (
972982 p. cargo ( "fix" ) ,
@@ -978,7 +988,6 @@ fix` can potentially perform destructive changes; if you'd like to \
978988 suppress this error pass `--allow-dirty`, or commit the changes to \
979989 these files:
980990
981- * Cargo.toml
982991 * src/lib.rs
983992
984993
@@ -1023,3 +1032,39 @@ fn does_not_warn_about_clean_working_directory() {
10231032 execs ( ) . with_status ( 0 ) ,
10241033 ) ;
10251034}
1035+
1036+ #[ test]
1037+ fn does_not_warn_about_dirty_ignored_files ( ) {
1038+ let p = project ( )
1039+ . file (
1040+ "Cargo.toml" ,
1041+ r#"
1042+ [package]
1043+ name = "foo"
1044+ version = "0.1.0"
1045+ "# ,
1046+ )
1047+ . file (
1048+ "src/lib.rs" ,
1049+ r#"
1050+ pub fn foo() {
1051+ }
1052+ "# ,
1053+ )
1054+ . file ( ".gitignore" , "foo\n " )
1055+ . build ( ) ;
1056+
1057+ let repo = git2:: Repository :: init ( & p. root ( ) ) . unwrap ( ) ;
1058+ let mut cfg = t ! ( repo. config( ) ) ;
1059+ t ! ( cfg
. set_str
( "user.email" , "[email protected] " ) ) ; 1060+ t ! ( cfg. set_str( "user.name" , "Foo Bar" ) ) ;
1061+ drop ( cfg) ;
1062+ git:: add ( & repo) ;
1063+ git:: commit ( & repo) ;
1064+ File :: create ( p. root ( ) . join ( "foo" ) ) . unwrap ( ) ;
1065+
1066+ assert_that (
1067+ p. cargo ( "fix" ) ,
1068+ execs ( ) . with_status ( 0 ) ,
1069+ ) ;
1070+ }
0 commit comments