From 66a0f6cb6592eedc6c357f3bb02840dc93e7d05d Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 22 Apr 2021 20:56:59 -0600 Subject: only recurse into actual directories --- src/state.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/state.rs b/src/state.rs index ed7f196..9a2488b 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,4 +1,4 @@ -use std::fs::read_dir; +use std::fs::{metadata, read_dir}; use std::io; use std::path::{Path, PathBuf}; @@ -26,7 +26,10 @@ fn find_repos_in(dir: impl AsRef) -> Result> { match Repository::open_bare(subdir.path()) { Ok(repo) => result.push(repo), Err(err) if err.class() == git2::ErrorClass::Repository && err.code() == git2::ErrorCode::NotFound => { - result.extend(find_repos_in(subdir.path())?) + let metadata = metadata(subdir.path())?; + if metadata.is_dir() { + result.extend(find_repos_in(subdir.path())?) + } } // TODO handle in a non-god-awful way Err(err) => panic!("{}", err), -- cgit v1.2.3