1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use glob::glob; use indicatif::ProgressBar; pub fn find_projects(root_folder: String) -> Vec<String> { let spinner = ProgressBar::new_spinner(); spinner.set_message(&format!( "Searching for git project with base folder {}", root_folder )); let mut projects: Vec<String> = vec![]; for mut path in glob(&format!("{}/**/.git", root_folder)) .unwrap() .filter_map(Result::ok) .filter(|p| p.is_dir()) { spinner.tick(); path.pop(); match path.to_str() { Some(str) => projects.push(str.to_string()), None => { println!( "Failed to convert {}, not an utf8 path name", path.display() ); } } } spinner.finish_with_message("done."); projects }