diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-01-08 11:36:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 11:36:11 -0500 |
commit | 3c245e6b55c06cce533606360acd5e0946a4f641 (patch) | |
tree | 2c325ca9eb59a9da4782750df56b72fe9b768db7 /src/tests/integration_test_utils.rs | |
parent | 60aa0cc14714da2bdc3b05686253f757869f697c (diff) | |
parent | 18719057a9901be9de560cd3ee78b39bd60d9d4b (diff) |
Merge pull request #495 from dandavison/493-GIT_CONFIG_PARAMETERS
Honor GIT_CONFIG_PARAMETERS env var
Diffstat (limited to 'src/tests/integration_test_utils.rs')
-rw-r--r-- | src/tests/integration_test_utils.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/tests/integration_test_utils.rs b/src/tests/integration_test_utils.rs index 37ae0575..8eb36748 100644 --- a/src/tests/integration_test_utils.rs +++ b/src/tests/integration_test_utils.rs @@ -18,11 +18,28 @@ pub mod integration_test_utils { git_config_contents: Option<&[u8]>, git_config_path: Option<&str>, ) -> cli::Opt { + _make_options_from_args_and_git_config(args, git_config_contents, git_config_path, false) + } + + pub fn make_options_from_args_and_git_config_honoring_env_var( + args: &[&str], + git_config_contents: Option<&[u8]>, + git_config_path: Option<&str>, + ) -> cli::Opt { + _make_options_from_args_and_git_config(args, git_config_contents, git_config_path, true) + } + + fn _make_options_from_args_and_git_config( + args: &[&str], + git_config_contents: Option<&[u8]>, + git_config_path: Option<&str>, + honor_env_var: bool, + ) -> cli::Opt { let mut args: Vec<&str> = itertools::chain(&["/dev/null", "/dev/null"], args) .map(|s| *s) .collect(); let mut git_config = match (git_config_contents, git_config_path) { - (Some(contents), Some(path)) => Some(make_git_config(contents, path)), + (Some(contents), Some(path)) => Some(make_git_config(contents, path, honor_env_var)), _ => { args.push("--no-gitconfig"); None @@ -52,11 +69,11 @@ pub mod integration_test_utils { config::Config::from(make_options_from_args(args)) } - fn make_git_config(contents: &[u8], path: &str) -> GitConfig { + fn make_git_config(contents: &[u8], path: &str, honor_env_var: bool) -> GitConfig { let path = Path::new(path); let mut file = File::create(path).unwrap(); file.write_all(contents).unwrap(); - GitConfig::from_path(&path) + GitConfig::from_path(&path, honor_env_var) } pub fn get_line_of_code_from_delta( |