From afaf707c2b0877262f0a2c5da5b25a7c89097b37 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:36:30 +0200 Subject: [PATCH] fix(backend)!: Use correct merge stratgy for repository options (#291) This fixes the merge strategy for values of `options`, `options_hot`, and `options_cold` to ignore incoming elements if they are already existing in the HashMap. The prior implementation was overwriting the values. Breaking change: The freestanding and public `extend` function has been removed. You can use `conflate::hashmap::overwrite` as a replacement. --------- Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> Co-authored-by: Alexander Weiss Co-authored-by: aawsome <37850842+aawsome@users.noreply.github.com> --- crates/backend/src/choose.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/crates/backend/src/choose.rs b/crates/backend/src/choose.rs index 7dbd425e..e7ec87d1 100644 --- a/crates/backend/src/choose.rs +++ b/crates/backend/src/choose.rs @@ -50,33 +50,20 @@ pub struct BackendOptions { /// Other options for this repository (hot and cold part) #[cfg_attr(feature = "clap", clap(skip))] - #[cfg_attr(feature = "merge", merge(strategy = extend))] + #[cfg_attr(feature = "merge", merge(strategy = conflate::hashmap::ignore))] pub options: HashMap, /// Other options for the hot repository #[cfg_attr(feature = "clap", clap(skip))] - #[cfg_attr(feature = "merge", merge(strategy = extend))] + #[cfg_attr(feature = "merge", merge(strategy = conflate::hashmap::ignore))] pub options_hot: HashMap, /// Other options for the cold repository #[cfg_attr(feature = "clap", clap(skip))] - #[cfg_attr(feature = "merge", merge(strategy = extend))] + #[cfg_attr(feature = "merge", merge(strategy = conflate::hashmap::ignore))] pub options_cold: HashMap, } -/// Overwrite the left value with the right value -/// -/// This is used for merging config values, e.g. [`BackendOptions`]. -/// -/// # Arguments -/// -/// * `left` - The left value -/// * `right` - The right value -#[cfg(feature = "merge")] -pub fn extend + IntoIterator>(left: &mut T, right: T) { - left.extend(right); -} - impl BackendOptions { /// Convert the options to backends. ///