File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1+ use std:: collections:: HashSet ;
12use std:: ffi:: OsStr ;
23use std:: fs:: File ;
34use std:: io:: Read ;
4- use std:: path:: Path ;
5+ use std:: path:: { Path , PathBuf } ;
56
7+ use build_helper:: git:: get_git_untracked_files;
68use ignore:: DirEntry ;
79
810/// The default directory filter.
@@ -75,12 +77,20 @@ pub(crate) fn walk_no_read(
7577 skip : impl Send + Sync + ' static + Fn ( & Path , bool ) -> bool ,
7678 f : & mut dyn FnMut ( & DirEntry ) ,
7779) {
80+ let untracked_files: HashSet < PathBuf > = match get_git_untracked_files ( Some ( paths[ 0 ] ) ) {
81+ Ok ( Some ( untracked_paths) ) => {
82+ untracked_paths. into_iter ( ) . map ( |s| PathBuf :: from ( paths[ 0 ] ) . join ( s) ) . collect ( )
83+ }
84+ _ => HashSet :: new ( ) ,
85+ } ;
86+
7887 let mut walker = ignore:: WalkBuilder :: new ( paths[ 0 ] ) ;
7988 for path in & paths[ 1 ..] {
8089 walker. add ( path) ;
8190 }
8291 let walker = walker. filter_entry ( move |e| {
8392 !skip ( e. path ( ) , e. file_type ( ) . map ( |ft| ft. is_dir ( ) ) . unwrap_or ( false ) )
93+ && !untracked_files. contains ( e. path ( ) )
8494 } ) ;
8595 for entry in walker. build ( ) . flatten ( ) {
8696 if entry. file_type ( ) . is_none_or ( |kind| kind. is_dir ( ) || kind. is_symlink ( ) ) {
You can’t perform that action at this time.
0 commit comments