Skip to content

Commit d93fe8a

Browse files
committed
more adapted error message in case of wrong folder
1 parent 17ea45d commit d93fe8a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: src/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ struct Configuration {
216216
}
217217

218218
fn get_configuration() -> Result<Configuration> {
219-
let repo = Repository::open("./").map_err(|_| Error::GitNotInstalled)?;
219+
let repo = Repository::open("./").map_err(|_| Error::NotGitRepo)?;
220220
let config = repo.config().map_err(|_| Error::NoGitData)?;
221221
let mut remote_url = String::new();
222222
let mut repository_name = String::new();
@@ -409,6 +409,8 @@ enum Error {
409409
NoGitData,
410410
/// An IO error occoured while reading ./
411411
ReadDirectory,
412+
/// Not in a Git Repo
413+
NotGitRepo,
412414
}
413415

414416
impl fmt::Debug for Error {
@@ -417,7 +419,8 @@ impl fmt::Debug for Error {
417419
Error::SourceCodeNotFound => "Could not find any source code in this directory",
418420
Error::GitNotInstalled => "Git failed to execute",
419421
Error::NoGitData => "Could not retrieve git configuration data",
420-
Error::ReadDirectory => "Could read directory ./",
422+
Error::ReadDirectory => "Could not read directory ./",
423+
Error::NotGitRepo => "You are not at the root of a Git Repo",
421424
};
422425
write!(f, "{}", content)
423426
}

0 commit comments

Comments
 (0)