Removed the screen clear and added an ignore repos cli arg
parent
249a962441
commit
43e18129a1
|
@ -23,6 +23,9 @@ pub struct CliArgs {
|
|||
#[arg(short, long, num_args(0..), value_hint = ValueHint::DirPath)]
|
||||
pub repos: Option<Vec<PathBuf>>,
|
||||
|
||||
#[arg(short('i'), long("igore"), num_args(0..))]
|
||||
pub ignored_repos: Option<Vec<String>>,
|
||||
|
||||
#[arg(short, long, num_args(0..))]
|
||||
pub branches: Option<Vec<String>>,
|
||||
|
||||
|
|
25
src/main.rs
25
src/main.rs
|
@ -63,7 +63,7 @@ struct Author {
|
|||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
clear_screen();
|
||||
// clear_screen();
|
||||
|
||||
let args = CliArgs::parse();
|
||||
|
||||
|
@ -154,24 +154,33 @@ fn get_color_map() -> Vec<String> {
|
|||
.to_vec()
|
||||
}
|
||||
|
||||
fn find_git_repos(scan_path: &path::Path, repos: &mut Vec<PathBuf>, _args: &CliArgs) {
|
||||
fn find_git_repos(
|
||||
scan_path: &path::Path,
|
||||
repos: &mut Vec<PathBuf>,
|
||||
ignored_repos: &Vec<String>,
|
||||
_args: &CliArgs,
|
||||
) {
|
||||
let Ok(dirs) = scan_path.read_dir()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let dirs: Vec<_> = dirs
|
||||
.filter_map(|f| f.ok())
|
||||
.filter(|f| f.file_type().is_ok_and(|t| t.is_dir()))
|
||||
.filter_map(|d| d.ok())
|
||||
.filter(|d| {
|
||||
let dir_name = d.file_name().to_string_lossy().to_string();
|
||||
!ignored_repos.contains(&dir_name)
|
||||
})
|
||||
.filter(|d| d.file_type().is_ok_and(|t| t.is_dir()))
|
||||
.collect_vec();
|
||||
|
||||
let dirs = dirs.iter().map(|f| f.path());
|
||||
let dirs = dirs.iter().map(|d| d.path());
|
||||
|
||||
for dir in dirs {
|
||||
let filename = dir.file_name().unwrap_or_default().to_string_lossy();
|
||||
match filename.as_ref() {
|
||||
".git" => repos.push(dir),
|
||||
_ => find_git_repos(&dir, repos, _args),
|
||||
_ => find_git_repos(&dir, repos, ignored_repos, _args),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,10 +192,12 @@ fn get_commits(
|
|||
) -> Result<(usize, Vec<Commit>)> {
|
||||
let mut commits: HashSet<Commit> = HashSet::new();
|
||||
|
||||
let ignored_repos = args.ignored_repos.as_ref().unwrap_or(&vec![]).to_owned();
|
||||
|
||||
let (repos, branches) = match &args.root_dir {
|
||||
Some(root) => {
|
||||
let mut repos: Vec<PathBuf> = vec![];
|
||||
find_git_repos(root, &mut repos, &args);
|
||||
find_git_repos(root, &mut repos, &ignored_repos, &args);
|
||||
let branches = vec!["".to_string(); repos.len()];
|
||||
(repos, branches)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue