From 873abe78d272e7a67f278d30b6063a4a0a5a8df8 Mon Sep 17 00:00:00 2001 From: malice00 Date: Wed, 2 Oct 2024 12:22:45 +0200 Subject: [PATCH] Duplicate properties (#1403) * Don't consider the project's name a profile Signed-off-by: Roland Asmann * Merging of properties was not correctly handled Signed-off-by: Roland Asmann --------- Signed-off-by: Roland Asmann --- lib/cli/index.js | 28 ++++++++++++---------------- lib/helpers/utils.js | 2 +- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/cli/index.js b/lib/cli/index.js index c130fc9b1..b15e76c8f 100644 --- a/lib/cli/index.js +++ b/lib/cli/index.js @@ -5473,19 +5473,20 @@ export function trimComponents(components) { } else { const existingComponent = keyCache[key]; // We need to retain any properties that differ - const compProps = existingComponent.properties || []; - const compPropsMap = {}; - for (const aprop of compProps) { - compPropsMap[aprop.name] = aprop.value; - } if (comp.properties) { - for (const newprop of comp.properties) { - if ( - !compPropsMap[newprop.name] || - (newprop.value && compPropsMap[newprop.name] !== newprop.value) - ) { - compProps.push(newprop); + if (existingComponent.properties) { + for (const newprop of comp.properties) { + if ( + !existingComponent.properties.find( + (prop) => + prop.name === newprop.name && prop.value === newprop.value, + ) + ) { + existingComponent.properties.push(newprop); + } } + } else { + existingComponent.properties = comp.properties; } } // If the component is required in any of the child projects, then make it required @@ -5494,11 +5495,6 @@ export function trimComponents(components) { comp?.scope === "required" ) { existingComponent.scope = "required"; - keyCache[key] = existingComponent; - } - if (compProps.length) { - existingComponent.properties = compProps; - keyCache[key] = existingComponent; } } } diff --git a/lib/helpers/utils.js b/lib/helpers/utils.js index ba9962118..f37aba3fd 100644 --- a/lib/helpers/utils.js +++ b/lib/helpers/utils.js @@ -2694,7 +2694,7 @@ export async function parseGradleDep( last_bomref = last_project_bomref; stack = [first_bomref]; } - if (rline.includes(" - ")) { + if (rline.includes(" - ") && !rline.startsWith("Project ':")) { profileName = rline.split(" - ")[0]; if (profileName.toLowerCase().includes("test")) { scope = "optional";