From 0a0f8c51162afe01cefe06ff5ef56e18e9a1efbd Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 1 Dec 2024 13:55:26 +0900 Subject: [PATCH] config: remove unneeded Result wrapping from resolved_config_values() --- cli/src/commands/config/list.rs | 2 +- cli/src/config.rs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cli/src/commands/config/list.rs b/cli/src/commands/config/list.rs index 6e8542ec6..76862fecc 100644 --- a/cli/src/commands/config/list.rs +++ b/cli/src/commands/config/list.rs @@ -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; diff --git a/cli/src/config.rs b/cli/src/config.rs index ff8519d95..9ba6a25e8 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -106,7 +106,7 @@ pub struct AnnotatedValue { pub fn resolved_config_values( stacked_config: &StackedConfig, filter_prefix: &ConfigNamePathBuf, -) -> Result, ConfigError> { +) -> Vec { // 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 {