summaryrefslogtreecommitdiff
path: root/src/git_config/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/git_config/mod.rs')
-rw-r--r--src/git_config/mod.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/git_config/mod.rs b/src/git_config/mod.rs
index 22fc604..fc59a84 100644
--- a/src/git_config/mod.rs
+++ b/src/git_config/mod.rs
@@ -6,7 +6,6 @@ use crate::env::DeltaEnv;
use regex::Regex;
use std::collections::HashMap;
use std::path::Path;
-use std::str::FromStr;
use lazy_static::lazy_static;
@@ -70,6 +69,17 @@ impl GitConfig {
None
}
+ #[cfg(test)]
+ pub fn for_testing() -> Option<Self> {
+ Some(GitConfig {
+ config: git2::Config::new().unwrap(),
+ config_from_env_var: HashMap::new(),
+ enabled: true,
+ repo: None,
+ path: std::path::PathBuf::from("/invalid_null.git"),
+ })
+ }
+
pub fn from_path(env: &DeltaEnv, path: &Path, honor_env_var: bool) -> Self {
use crate::fatal;
@@ -109,7 +119,9 @@ impl GitConfig {
}
}
+ #[cfg(not(test))]
pub fn get_remote_url(&self) -> Option<GitRemoteRepo> {
+ use std::str::FromStr;
self.repo
.as_ref()?
.find_remote("origin")