aboutsummaryrefslogtreecommitdiffstats
path: root/src/projects/entry.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-11-22 20:21:36 -0600
committerToby Vincent <tobyv13@gmail.com>2022-11-22 20:22:58 -0600
commit0f428974b2d7f4cf59490904564e52d134b9ef3a (patch)
tree9e29ce643d8f1e6352daa38e4476472a1cf59ba0 /src/projects/entry.rs
parent8c4e03340a39a966a06bdce0c948b5462774d020 (diff)
feat: add filtering and sorting for git repos
Diffstat (limited to 'src/projects/entry.rs')
-rw-r--r--src/projects/entry.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/projects/entry.rs b/src/projects/entry.rs
index 08ed07a..739ed83 100644
--- a/src/projects/entry.rs
+++ b/src/projects/entry.rs
@@ -1,4 +1,4 @@
-use ignore::{Walk, WalkBuilder};
+use ignore::{DirEntry, Walk, WalkBuilder};
use serde::{Deserialize, Deserializer, Serialize};
use std::{convert::Infallible, path::PathBuf, str::FromStr};
@@ -10,6 +10,12 @@ pub struct SearchPath {
pub max_depth: Option<usize>,
}
+impl SearchPath {
+ pub fn filter(dir_entry: &DirEntry) -> bool {
+ dir_entry.path().join(".git").exists()
+ }
+}
+
impl From<PathBuf> for SearchPath {
fn from(path: PathBuf) -> Self {
Self {
@@ -25,6 +31,7 @@ impl From<SearchPath> for Walk {
.standard_filters(true)
.max_depth(value.max_depth)
.hidden(!value.hidden)
+ .filter_entry(SearchPath::filter)
.build()
}
}