From 7a77343ec3ddb99fbbc4b46d2dd6b0dce6c80d60 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:53:04 +0100 Subject: Add more verbose error if ./. is not a git repository Signed-off-by: Matthias Beyer --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index bcd3631..4c7c630 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,7 @@ use std::path::PathBuf; use anyhow::anyhow; use anyhow::Context; +use anyhow::Error; use anyhow::Result; use clap::ArgMatches; use logcrate::debug; @@ -90,6 +91,10 @@ async fn main() -> Result<()> { let cli = app.get_matches(); let repo = git2::Repository::discover(PathBuf::from(".")) + .map_err(|e| match e.code() { + git2::ErrorCode::NotFound => anyhow!("Failed to load the git repository from ./."), + _ => Error::from(e), + }) .context("Loading the git repository") .context("Butido must be executed within the package repository")?; let repo_path = repo -- cgit v1.2.3