diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/state.rs | 19 |
1 files 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<Path>) -> Result<Vec<Repository>> { 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) } } |