-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
GIT_CONFIG_NOSYSTEM
now also affects the installation directory.
It makes sense to consider it part of the 'system', and allows for proper isolation of `gix` operations, for example in tests. This is also a fix, as previously it checked for `...NO_SYSTEM`, instead of `NOSYSTEM`.
- Loading branch information
Showing
3 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ pub use gix_testtools::Result; | |
|
||
mod file; | ||
mod parse; | ||
mod source; | ||
mod value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use gix_config::Source; | ||
use std::path::Path; | ||
|
||
#[test] | ||
fn git_config_no_system() { | ||
assert_eq!( | ||
Source::GitInstallation.storage_location(&mut |name| { | ||
assert_eq!( | ||
name, "GIT_CONFIG_NOSYSTEM", | ||
"it only checks this var, and if set, nothing else" | ||
); | ||
Some("1".into()) | ||
}), | ||
None | ||
); | ||
assert_eq!( | ||
Source::System.storage_location(&mut |name| { | ||
assert_eq!( | ||
name, "GIT_CONFIG_NOSYSTEM", | ||
"it only checks this var, and if set, nothing else" | ||
); | ||
Some("1".into()) | ||
}), | ||
None | ||
); | ||
} | ||
|
||
#[test] | ||
fn git_config_system() { | ||
assert_eq!( | ||
Source::System | ||
.storage_location(&mut |name| { | ||
match name { | ||
"GIT_CONFIG_NOSYSTEM" => None, | ||
"GIT_CONFIG_SYSTEM" => Some("alternative".into()), | ||
unexpected => unreachable!("unexpected env var: {unexpected}"), | ||
} | ||
}) | ||
.expect("set") | ||
.as_ref(), | ||
Path::new("alternative"), | ||
"we respect the system config variable for overrides" | ||
); | ||
} | ||
|
||
#[test] | ||
fn git_config_global() { | ||
for source in [Source::Git, Source::User] { | ||
assert_eq!( | ||
source | ||
.storage_location(&mut |name| { | ||
assert_eq!( | ||
name, "GIT_CONFIG_GLOBAL", | ||
"it only checks this var, and if set, nothing else" | ||
); | ||
Some("alternative".into()) | ||
}) | ||
.expect("set") | ||
.as_ref(), | ||
Path::new("alternative"), | ||
"we respect the global config variable for 'git' overrides" | ||
); | ||
} | ||
} |