From 8d261ee9fd97e9b13cebdaa1cbb8dcddf4a6cbd3 Mon Sep 17 00:00:00 2001 From: ATechnoHazard Date: Wed, 14 Oct 2020 01:46:11 +0530 Subject: [PATCH] search: skip empty repos Signed-off-by: ATechnoHazard --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3bd9929..5df6857 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,10 +16,15 @@ fn main() -> anyhow::Result<()> { let path = format!("{}/.git", entry.path().display()); let git_dir = Path::new(&path); if git_dir.exists() { + let repo = Repository::open(git_dir)?; + if repo.is_empty()? { + continue; + } + items.push(format!( "{} = {}", entry.path().to_string_lossy().to_string(), - Repository::open(git_dir)?.head()?.name().unwrap_or("None") + repo.head()?.name().unwrap_or("None") )); } };