diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-03-11 08:53:04 +0100 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-03-11 08:53:04 +0100 |
commit | 7a77343ec3ddb99fbbc4b46d2dd6b0dce6c80d60 (patch) | |
tree | 4bb4bcd12cc214a7add24a4e880a067adcd2f34c | |
parent | fce4f0ed532b8d2753199f88cdaaa41dcbbf80f4 (diff) |
Add more verbose error if ./. is not a git repository
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r-- | src/main.rs | 5 |
1 files changed, 5 insertions, 0 deletions
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 |