File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ pub fn check(_path: &Path, _bad: &mut bool) {}
24
24
#[ cfg( unix) ]
25
25
pub fn check ( path : & Path , bad : & mut bool ) {
26
26
use std:: fs;
27
+ use std:: process:: { Command , Stdio } ;
27
28
use std:: os:: unix:: prelude:: * ;
28
29
29
30
super :: walk ( path,
@@ -37,8 +38,22 @@ pub fn check(path: &Path, bad: &mut bool) {
37
38
38
39
let metadata = t ! ( fs:: symlink_metadata( & file) , & file) ;
39
40
if metadata. mode ( ) & 0o111 != 0 {
40
- println ! ( "binary checked into source: {}" , file. display( ) ) ;
41
- * bad = true ;
41
+ let rel_path = file. strip_prefix ( path) . unwrap ( ) ;
42
+ let git_friendly_path = rel_path. to_str ( ) . unwrap ( ) . replace ( "\\ " , "/" ) ;
43
+ let ret_code = Command :: new ( "git" )
44
+ . arg ( "ls-files" )
45
+ . arg ( & git_friendly_path)
46
+ . current_dir ( path)
47
+ . stdout ( Stdio :: null ( ) )
48
+ . stderr ( Stdio :: null ( ) )
49
+ . status ( )
50
+ . unwrap_or_else ( |e| {
51
+ panic ! ( "could not run git ls-files: {}" , e) ;
52
+ } ) ;
53
+ if ret_code. success ( ) {
54
+ println ! ( "binary checked into source: {}" , file. display( ) ) ;
55
+ * bad = true ;
56
+ }
42
57
}
43
58
} )
44
59
}
You can’t perform that action at this time.
0 commit comments