Skip to content

Commit a08df69

Browse files
committed
fix: panic substituted with generic error message
1 parent 2f082ec commit a08df69

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/git_commands.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use crate::utils::display_link;
1+
use crate::{confirm_prompt, fail, utils::display_link};
22
use colored::Colorize;
3+
use futures::future::UnitError;
34
use std::{
45
path::{Path, PathBuf},
56
process::Output,
@@ -56,8 +57,13 @@ pub fn get_git_root() -> anyhow::Result<PathBuf> {
5657
get_git_output(root, &args).map(|output| output.into())
5758
}
5859

59-
pub static GIT_ROOT: Lazy<PathBuf> =
60-
Lazy::new(|| get_git_root().expect("Failed to determine Git root directory"));
60+
pub static GIT_ROOT: Lazy<PathBuf> = Lazy::new(|| match get_git_root() {
61+
Ok(root) => root,
62+
Err(err) => {
63+
fail!("Failed to determine Git root directory.\n{err}");
64+
std::process::exit(1)
65+
}
66+
});
6167

6268
type Git = Lazy<Box<dyn Fn(&[&str]) -> Result<String> + Send + Sync>>;
6369

0 commit comments

Comments
 (0)