1
1
use std:: fs:: File ;
2
2
3
- use git2;
4
-
5
3
use crate :: support:: git;
6
4
use crate :: support:: { basic_manifest, clippy_is_available, is_nightly, project} ;
7
5
@@ -710,15 +708,8 @@ fn warns_if_no_vcs_detected() {
710
708
711
709
#[ cargo_test]
712
710
fn warns_about_dirty_working_directory ( ) {
713
- let p = project ( ) . file ( "src/lib.rs" , "pub fn foo() {}" ) . build ( ) ;
711
+ let p = git :: new ( "foo" , |p| p . file ( "src/lib.rs" , "pub fn foo() {}" ) ) ;
714
712
715
- let repo = git2:: Repository :: init ( & p. root ( ) ) . unwrap ( ) ;
716
- let mut cfg = t ! ( repo. config( ) ) ;
717
- t ! ( cfg
. set_str
( "user.email" , "[email protected] " ) ) ;
718
- t ! ( cfg. set_str( "user.name" , "Foo Bar" ) ) ;
719
- drop ( cfg) ;
720
- git:: add ( & repo) ;
721
- git:: commit ( & repo) ;
722
713
File :: create ( p. root ( ) . join ( "src/lib.rs" ) ) . unwrap ( ) ;
723
714
724
715
p. cargo ( "fix" )
@@ -741,15 +732,8 @@ commit the changes to these files:
741
732
742
733
#[ cargo_test]
743
734
fn warns_about_staged_working_directory ( ) {
744
- let p = project ( ) . file ( "src/lib.rs" , "pub fn foo() {}" ) . build ( ) ;
735
+ let ( p , repo ) = git :: new_repo ( "foo" , |p| p . file ( "src/lib.rs" , "pub fn foo() {}" ) ) ;
745
736
746
- let repo = git2:: Repository :: init ( & p. root ( ) ) . unwrap ( ) ;
747
- let mut cfg = t ! ( repo. config( ) ) ;
748
- t ! ( cfg
. set_str
( "user.email" , "[email protected] " ) ) ;
749
- t ! ( cfg. set_str( "user.name" , "Foo Bar" ) ) ;
750
- drop ( cfg) ;
751
- git:: add ( & repo) ;
752
- git:: commit ( & repo) ;
753
737
File :: create ( & p. root ( ) . join ( "src/lib.rs" ) )
754
738
. unwrap ( )
755
739
. write_all ( "pub fn bar() {}" . to_string ( ) . as_bytes ( ) )
@@ -776,33 +760,17 @@ commit the changes to these files:
776
760
777
761
#[ cargo_test]
778
762
fn does_not_warn_about_clean_working_directory ( ) {
779
- let p = project ( ) . file ( "src/lib.rs" , "pub fn foo() {}" ) . build ( ) ;
780
-
781
- let repo = git2:: Repository :: init ( & p. root ( ) ) . unwrap ( ) ;
782
- let mut cfg = t ! ( repo. config( ) ) ;
783
- t ! ( cfg
. set_str
( "user.email" , "[email protected] " ) ) ;
784
- t ! ( cfg. set_str( "user.name" , "Foo Bar" ) ) ;
785
- drop ( cfg) ;
786
- git:: add ( & repo) ;
787
- git:: commit ( & repo) ;
788
-
763
+ let p = git:: new ( "foo" , |p| p. file ( "src/lib.rs" , "pub fn foo() {}" ) ) ;
789
764
p. cargo ( "fix" ) . run ( ) ;
790
765
}
791
766
792
767
#[ cargo_test]
793
768
fn does_not_warn_about_dirty_ignored_files ( ) {
794
- let p = project ( )
795
- . file ( "src/lib.rs" , "pub fn foo() {}" )
796
- . file ( ".gitignore" , "bar\n " )
797
- . build ( ) ;
769
+ let p = git :: new ( "foo" , |p| {
770
+ p . file ( "src/lib.rs" , "pub fn foo() {}" )
771
+ . file ( ".gitignore" , "bar\n " )
772
+ } ) ;
798
773
799
- let repo = git2:: Repository :: init ( & p. root ( ) ) . unwrap ( ) ;
800
- let mut cfg = t ! ( repo. config( ) ) ;
801
- t ! ( cfg
. set_str
( "user.email" , "[email protected] " ) ) ;
802
- t ! ( cfg. set_str( "user.name" , "Foo Bar" ) ) ;
803
- drop ( cfg) ;
804
- git:: add ( & repo) ;
805
- git:: commit ( & repo) ;
806
774
File :: create ( p. root ( ) . join ( "bar" ) ) . unwrap ( ) ;
807
775
808
776
p. cargo ( "fix" ) . run ( ) ;
@@ -1267,8 +1235,7 @@ fn fix_in_existing_repo_weird_ignore() {
1267
1235
. file ( "src/lib.rs" , "" )
1268
1236
. file ( ".gitignore" , "foo\n inner\n " )
1269
1237
. file ( "inner/file" , "" )
1270
- } )
1271
- . unwrap ( ) ;
1238
+ } ) ;
1272
1239
1273
1240
p. cargo ( "fix" ) . run ( ) ;
1274
1241
// This is questionable about whether it is the right behavior. It should
0 commit comments