From 3905b6ff0c6bdf11290ea8bd1c920b4d14b6f8ca Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 22 Apr 2021 20:40:16 -0600 Subject: appease the paperclip --- src/state.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/state.rs b/src/state.rs index 475302b..645a4b6 100644 --- a/src/state.rs +++ b/src/state.rs @@ -16,18 +16,15 @@ fn find_repos_in(dir: impl AsRef) -> Result> { let dir = read_dir(dir)?; let mut result = vec![]; for subdir in dir { - match subdir { - Ok(subdir) => { - 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())?) - } - // TODO handle in a non-god-awful way - Err(err) => panic!("{}", err), + if let Ok(subdir) = subdir { + 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())?) } + // TODO handle in a non-god-awful way + Err(err) => panic!("{}", err), } - Err(_) => {}, } } Ok(result) @@ -41,6 +38,6 @@ impl State { } pub fn relative_path<'a>(&'a self, subdir: &'a Path) -> &'a Path { - subdir.strip_prefix(&self.root).unwrap_or_else(|_| subdir.as_ref()) + subdir.strip_prefix(&self.root).unwrap_or(subdir) } } -- cgit v1.2.3