-
-
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.
Merge pull request #1656 from GitoxideLabs/hasconfig
hasconfig:remote.*.url
- Loading branch information
Showing
45 changed files
with
421 additions
and
130 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
gix-config/tests/config/file/init/from_paths/includes/conditional/hasconfig.rs
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,78 @@ | ||
use gix_config::file::{includes, init}; | ||
use std::path::{Path, PathBuf}; | ||
|
||
#[test] | ||
fn simple() -> crate::Result { | ||
let (config, root) = config_with_includes("basic")?; | ||
compare_baseline(&config, "user.this", root.join("expected")); | ||
assert_eq!(config.string("user.that"), None); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn inclusion_order() -> crate::Result { | ||
let (config, root) = config_with_includes("inclusion-order")?; | ||
for key in ["one", "two", "three"] { | ||
compare_baseline(&config, format!("user.{key}"), root.join(format!("expected.{key}"))); | ||
} | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn globs() -> crate::Result { | ||
let (config, root) = config_with_includes("globs")?; | ||
for key in ["dss", "dse", "dsm", "ssm"] { | ||
compare_baseline(&config, format!("user.{key}"), root.join(format!("expected.{key}"))); | ||
} | ||
assert_eq!(config.string("user.no"), None); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn cycle_breaker() -> crate::Result { | ||
for name in ["cycle-breaker-direct", "cycle-breaker-indirect"] { | ||
let (_config, _root) = config_with_includes(name)?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn no_cycle() -> crate::Result { | ||
let (config, root) = config_with_includes("no-cycle")?; | ||
compare_baseline(&config, "user.name", root.join("expected")); | ||
Ok(()) | ||
} | ||
|
||
fn compare_baseline(config: &gix_config::File<'static>, key: impl AsRef<str>, expected: impl AsRef<Path>) { | ||
let expected = expected.as_ref(); | ||
let key = key.as_ref(); | ||
assert_eq!( | ||
config | ||
.string(key) | ||
.unwrap_or_else(|| panic!("key '{key} should be included")) | ||
.as_ref(), | ||
std::fs::read_to_string(expected) | ||
.unwrap_or_else(|err| panic!("Couldn't find '{expected:?}' for reading: {err}")) | ||
.trim(), | ||
"baseline with git should match: '{key}' != {expected:?}" | ||
); | ||
} | ||
|
||
fn config_with_includes(name: &str) -> crate::Result<(gix_config::File<'static>, PathBuf)> { | ||
let root = gix_testtools::scripted_fixture_read_only_standalone("hasconfig.sh")?.join(name); | ||
let options = init::Options { | ||
includes: includes::Options::follow(Default::default(), Default::default()), | ||
..Default::default() | ||
}; | ||
|
||
let config = gix_config::File::from_paths_metadata( | ||
Some(gix_config::file::Metadata::try_from_path( | ||
root.join("config"), | ||
gix_config::Source::Local, | ||
)?), | ||
options, | ||
)? | ||
.expect("non-empty"); | ||
Ok((config, root)) | ||
} |
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
Oops, something went wrong.