search: skip empty repos

Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
ATechnoHazard 2020-10-14 01:46:11 +05:30
parent f0da001acb
commit 8d261ee9fd
No known key found for this signature in database
GPG key ID: F475143EDEDEBA3C

View file

@ -16,10 +16,15 @@ fn main() -> anyhow::Result<()> {
let path = format!("{}/.git", entry.path().display()); let path = format!("{}/.git", entry.path().display());
let git_dir = Path::new(&path); let git_dir = Path::new(&path);
if git_dir.exists() { if git_dir.exists() {
let repo = Repository::open(git_dir)?;
if repo.is_empty()? {
continue;
}
items.push(format!( items.push(format!(
"{} = {}", "{} = {}",
entry.path().to_string_lossy().to_string(), entry.path().to_string_lossy().to_string(),
Repository::open(git_dir)?.head()?.name().unwrap_or("None") repo.head()?.name().unwrap_or("None")
)); ));
} }
}; };