@@ -103,36 +103,40 @@ mod os_impl {
103103
104104 // FIXME: we don't need to look at all binaries, only files that have been modified in this branch
105105 // (e.g. using `git ls-files`).
106- walk_no_read ( & [ path] , |path| filter_dirs ( path) || path. ends_with ( "src/etc" ) , & mut |entry| {
107- let file = entry. path ( ) ;
108- let extension = file. extension ( ) ;
109- let scripts = [ "py" , "sh" , "ps1" ] ;
110- if scripts. into_iter ( ) . any ( |e| extension == Some ( OsStr :: new ( e) ) ) {
111- return ;
112- }
113-
114- if t ! ( is_executable( & file) , file) {
115- let rel_path = file. strip_prefix ( path) . unwrap ( ) ;
116- let git_friendly_path = rel_path. to_str ( ) . unwrap ( ) . replace ( "\\ " , "/" ) ;
117-
118- if ALLOWED . contains ( & git_friendly_path. as_str ( ) ) {
106+ walk_no_read (
107+ & [ path] ,
108+ |path, _is_dir| filter_dirs ( path) || path. ends_with ( "src/etc" ) ,
109+ & mut |entry| {
110+ let file = entry. path ( ) ;
111+ let extension = file. extension ( ) ;
112+ let scripts = [ "py" , "sh" , "ps1" ] ;
113+ if scripts. into_iter ( ) . any ( |e| extension == Some ( OsStr :: new ( e) ) ) {
119114 return ;
120115 }
121116
122- let output = Command :: new ( "git" )
123- . arg ( "ls-files" )
124- . arg ( & git_friendly_path)
125- . current_dir ( path)
126- . stderr ( Stdio :: null ( ) )
127- . output ( )
128- . unwrap_or_else ( |e| {
129- panic ! ( "could not run git ls-files: {e}" ) ;
130- } ) ;
131- let path_bytes = rel_path. as_os_str ( ) . as_bytes ( ) ;
132- if output. status . success ( ) && output. stdout . starts_with ( path_bytes) {
133- tidy_error ! ( bad, "binary checked into source: {}" , file. display( ) ) ;
117+ if t ! ( is_executable( & file) , file) {
118+ let rel_path = file. strip_prefix ( path) . unwrap ( ) ;
119+ let git_friendly_path = rel_path. to_str ( ) . unwrap ( ) . replace ( "\\ " , "/" ) ;
120+
121+ if ALLOWED . contains ( & git_friendly_path. as_str ( ) ) {
122+ return ;
123+ }
124+
125+ let output = Command :: new ( "git" )
126+ . arg ( "ls-files" )
127+ . arg ( & git_friendly_path)
128+ . current_dir ( path)
129+ . stderr ( Stdio :: null ( ) )
130+ . output ( )
131+ . unwrap_or_else ( |e| {
132+ panic ! ( "could not run git ls-files: {e}" ) ;
133+ } ) ;
134+ let path_bytes = rel_path. as_os_str ( ) . as_bytes ( ) ;
135+ if output. status . success ( ) && output. stdout . starts_with ( path_bytes) {
136+ tidy_error ! ( bad, "binary checked into source: {}" , file. display( ) ) ;
137+ }
134138 }
135- }
136- } )
139+ } ,
140+ )
137141 }
138142}
0 commit comments