mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 16:53:25 +00:00
config: remove unneeded Result wrapping from resolved_config_values()
This commit is contained in:
parent
23b24120fb
commit
0a0f8c5116
2 changed files with 6 additions and 7 deletions
|
@ -79,7 +79,7 @@ pub fn cmd_config_list(
|
||||||
let mut formatter = ui.stdout_formatter();
|
let mut formatter = ui.stdout_formatter();
|
||||||
let name_path = args.name.clone().unwrap_or_else(ConfigNamePathBuf::root);
|
let name_path = args.name.clone().unwrap_or_else(ConfigNamePathBuf::root);
|
||||||
let mut wrote_values = false;
|
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.
|
// Remove overridden values.
|
||||||
if annotated.is_overridden && !args.include_overridden {
|
if annotated.is_overridden && !args.include_overridden {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -106,7 +106,7 @@ pub struct AnnotatedValue {
|
||||||
pub fn resolved_config_values(
|
pub fn resolved_config_values(
|
||||||
stacked_config: &StackedConfig,
|
stacked_config: &StackedConfig,
|
||||||
filter_prefix: &ConfigNamePathBuf,
|
filter_prefix: &ConfigNamePathBuf,
|
||||||
) -> Result<Vec<AnnotatedValue>, ConfigError> {
|
) -> Vec<AnnotatedValue> {
|
||||||
// Collect annotated values from each config.
|
// Collect annotated values from each config.
|
||||||
let mut config_vals = vec![];
|
let mut config_vals = vec![];
|
||||||
for layer in stacked_config.layers() {
|
for layer in stacked_config.layers() {
|
||||||
|
@ -147,7 +147,7 @@ pub fn resolved_config_values(
|
||||||
val.is_overridden = !names_found.insert(&val.name);
|
val.is_overridden = !names_found.insert(&val.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(config_vals)
|
config_vals
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -759,7 +759,7 @@ mod tests {
|
||||||
fn test_resolved_config_values_empty() {
|
fn test_resolved_config_values_empty() {
|
||||||
let config = StackedConfig::empty();
|
let config = StackedConfig::empty();
|
||||||
assert_eq!(
|
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));
|
config.add_layer(ConfigLayer::with_data(ConfigSource::Repo, repo_config));
|
||||||
// Note: "email" is alphabetized, before "name" from same layer.
|
// Note: "email" is alphabetized, before "name" from same layer.
|
||||||
insta::assert_debug_snapshot!(
|
insta::assert_debug_snapshot!(
|
||||||
resolved_config_values(&config, &ConfigNamePathBuf::root()).unwrap(),
|
resolved_config_values(&config, &ConfigNamePathBuf::root()),
|
||||||
@r#"
|
@r#"
|
||||||
[
|
[
|
||||||
AnnotatedValue {
|
AnnotatedValue {
|
||||||
|
@ -926,8 +926,7 @@ mod tests {
|
||||||
config.add_layer(ConfigLayer::with_data(ConfigSource::User, user_config));
|
config.add_layer(ConfigLayer::with_data(ConfigSource::User, user_config));
|
||||||
config.add_layer(ConfigLayer::with_data(ConfigSource::Repo, repo_config));
|
config.add_layer(ConfigLayer::with_data(ConfigSource::Repo, repo_config));
|
||||||
insta::assert_debug_snapshot!(
|
insta::assert_debug_snapshot!(
|
||||||
resolved_config_values(&config, &ConfigNamePathBuf::from_iter(["test-table1"]))
|
resolved_config_values(&config, &ConfigNamePathBuf::from_iter(["test-table1"])),
|
||||||
.unwrap(),
|
|
||||||
@r#"
|
@r#"
|
||||||
[
|
[
|
||||||
AnnotatedValue {
|
AnnotatedValue {
|
||||||
|
|
Loading…
Reference in a new issue