diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-11-22 20:21:36 -0600 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-11-22 20:22:58 -0600 |
commit | 0f428974b2d7f4cf59490904564e52d134b9ef3a (patch) | |
tree | 9e29ce643d8f1e6352daa38e4476472a1cf59ba0 /src/projects.rs | |
parent | 8c4e03340a39a966a06bdce0c948b5462774d020 (diff) |
feat: add filtering and sorting for git repos
Diffstat (limited to 'src/projects.rs')
-rw-r--r-- | src/projects.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/projects.rs b/src/projects.rs index 23530a7..8819628 100644 --- a/src/projects.rs +++ b/src/projects.rs @@ -2,7 +2,7 @@ use crate::{Config, Result}; use figment::Provider; use ignore::Walk; use std::{path::PathBuf, vec::IntoIter}; -use tracing::warn; +use tracing::{error, info}; pub use entry::SearchPath; @@ -54,16 +54,15 @@ impl Iterator for Projects { #[tracing::instrument] fn next(&mut self) -> Option<Self::Item> { - if self.walk.is_none() { - self.walk = Some(self.search_path_iter.next()?.into()); - }; - - match self.walk.as_mut()?.next()? { - Ok(d) => Some(d.into_path()), - Err(err) => { - warn!("{:?}", err); - None - } + loop { + match self.walk.as_mut().and_then(|iter| iter.next()) { + Some(Ok(path)) if SearchPath::filter(&path) => return Some(path.into_path()), + Some(Ok(path)) => info!(?path, "Ignoring filtered path"), + Some(Err(err)) => error!(%err, "Ignoring errored path"), + None => { + self.walk = Some(self.search_path_iter.next()?.into()); + } + }; } } } |