config: remove unneeded Result wrapping from resolved_config_values()

This commit is contained in:
Yuya Nishihara 2024-12-01 13:55:26 +09:00
parent 23b24120fb
commit 0a0f8c5116
2 changed files with 6 additions and 7 deletions

View file

@ -79,7 +79,7 @@ pub fn cmd_config_list(
let mut formatter = ui.stdout_formatter();
let name_path = args.name.clone().unwrap_or_else(ConfigNamePathBuf::root);
let mut wrote_values = false;
for annotated in resolved_config_values(command.settings().config(), &name_path)? {
for annotated in resolved_config_values(command.settings().config(), &name_path) {
// Remove overridden values.
if annotated.is_overridden && !args.include_overridden {
continue;

View file

@ -106,7 +106,7 @@ pub struct AnnotatedValue {
pub fn resolved_config_values(
stacked_config: &StackedConfig,
filter_prefix: &ConfigNamePathBuf,
) -> Result<Vec<AnnotatedValue>, ConfigError> {
) -> Vec<AnnotatedValue> {
// Collect annotated values from each config.
let mut config_vals = vec![];
for layer in stacked_config.layers() {
@ -147,7 +147,7 @@ pub fn resolved_config_values(
val.is_overridden = !names_found.insert(&val.name);
}
Ok(config_vals)
config_vals
}
#[derive(Clone, Debug)]
@ -759,7 +759,7 @@ mod tests {
fn test_resolved_config_values_empty() {
let config = StackedConfig::empty();
assert_eq!(
resolved_config_values(&config, &ConfigNamePathBuf::root()).unwrap(),
resolved_config_values(&config, &ConfigNamePathBuf::root()),
[]
);
}
@ -786,7 +786,7 @@ mod tests {
config.add_layer(ConfigLayer::with_data(ConfigSource::Repo, repo_config));
// Note: "email" is alphabetized, before "name" from same layer.
insta::assert_debug_snapshot!(
resolved_config_values(&config, &ConfigNamePathBuf::root()).unwrap(),
resolved_config_values(&config, &ConfigNamePathBuf::root()),
@r#"
[
AnnotatedValue {
@ -926,8 +926,7 @@ mod tests {
config.add_layer(ConfigLayer::with_data(ConfigSource::User, user_config));
config.add_layer(ConfigLayer::with_data(ConfigSource::Repo, repo_config));
insta::assert_debug_snapshot!(
resolved_config_values(&config, &ConfigNamePathBuf::from_iter(["test-table1"]))
.unwrap(),
resolved_config_values(&config, &ConfigNamePathBuf::from_iter(["test-table1"])),
@r#"
[
AnnotatedValue {