@@ -5,7 +5,7 @@ use std::env;
55use std:: path:: PathBuf ;
66
77use clap:: Parser ;
8- use ignore:: { DirEntry , Walk } ;
8+ use ignore:: { DirEntry , WalkBuilder } ;
99use rayon:: prelude:: * ;
1010
1111use crate :: error:: Error ;
@@ -30,6 +30,15 @@ struct Options {
3030 ) ]
3131 directory : PathBuf ,
3232
33+ #[ arg( long, help = "Search hidden files and directories." ) ]
34+ hidden : bool ,
35+
36+ #[ arg(
37+ long,
38+ help = "When set, ignore files such as .gitignore will not be respected."
39+ ) ]
40+ no_ignore : bool ,
41+
3342 #[ arg( trailing_var_arg = true , required = true ) ]
3443 command : Vec < String > ,
3544}
@@ -42,7 +51,8 @@ fn main() {
4251/// subdirectories.
4352fn repository_foreach < T : Iterator < Item = String > > ( args : T ) -> Result < ( ) , Error > {
4453 let options = parse_options ( args) ?;
45- find_repositories ( & options. directory )
54+ dbg ! ( & options) ;
55+ find_repositories ( & options)
4656 . par_iter ( )
4757 . map ( |repository| run_command_in_directory ( & options, repository) )
4858 . collect ( )
@@ -54,9 +64,14 @@ fn parse_options<T: Iterator<Item = String>>(args: T) -> Result<Options, Error>
5464}
5565
5666/// Find all git repositories in a directory and its subdirectories.
57- fn find_repositories ( path : & PathBuf ) -> HashSet < PathBuf > {
58- Walk :: new ( path)
59- . flatten ( )
67+ fn find_repositories ( options : & Options ) -> HashSet < PathBuf > {
68+ let walk = WalkBuilder :: new ( & options. directory )
69+ . hidden ( options. hidden )
70+ . ignore ( !options. no_ignore )
71+ . git_ignore ( !options. no_ignore )
72+ . build ( ) ;
73+
74+ walk. flatten ( )
6075 . map ( DirEntry :: into_path)
6176 . filter ( |path| path. is_dir ( ) && path. join ( ".git" ) . exists ( ) )
6277 . collect ( )
0 commit comments