File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 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) {}
2424#[ cfg( unix) ]
2525pub fn check ( path : & Path , bad : & mut bool ) {
2626 use std:: fs;
27+ use std:: process:: { Command , Stdio } ;
2728 use std:: os:: unix:: prelude:: * ;
2829
2930 super :: walk ( path,
@@ -37,8 +38,22 @@ pub fn check(path: &Path, bad: &mut bool) {
3738
3839 let metadata = t ! ( fs:: symlink_metadata( & file) , & file) ;
3940 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+ }
4257 }
4358 } )
4459}
You can’t perform that action at this time.
0 commit comments