Skip to content

Commit

Permalink
Do not duplicate dependsOn (#1425) (#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
marob authored Oct 20, 2024
1 parent f974681 commit b89cb4c
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 158 deletions.
34 changes: 17 additions & 17 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ export async function createJavaBom(path, options) {
);
const allProjects = [];
const allProjectsAddedPurls = [];
const rootDependsOn = [];
const rootDependsOn = new Set();
const gradleModules = new Map();
// Determine the root path for gradle
// Fixes gradle invocation for microservices-demo
Expand Down Expand Up @@ -1673,7 +1673,7 @@ export async function createJavaBom(path, options) {
rootGradleModule = rootComponent;
} else if (!allProjectsAddedPurls.includes(rootComponent["purl"])) {
allProjects.push(rootComponent);
rootDependsOn.push(rootComponent["bom-ref"]);
rootDependsOn.add(rootComponent["bom-ref"]);
allProjectsAddedPurls.push(rootComponent["purl"]);
}
allProjectsStr = allProjectsStr.concat(retMap.projects);
Expand Down Expand Up @@ -1708,7 +1708,7 @@ export async function createJavaBom(path, options) {
);
if (!allProjectsAddedPurls.includes(rootSubProjectObj["purl"])) {
allProjects.push(rootSubProjectObj);
rootDependsOn.push(rootSubProjectObj["bom-ref"]);
rootDependsOn.add(rootSubProjectObj["bom-ref"]);
allProjectsAddedPurls.push(rootSubProjectObj["purl"]);
}
gradleModules.set(subProject, rootSubProjectObj);
Expand All @@ -1722,7 +1722,7 @@ export async function createJavaBom(path, options) {
});
dependencies.push({
ref: parentComponent["bom-ref"],
dependsOn: rootDependsOn,
dependsOn: [...rootDependsOn].sort(),
});
}
}
Expand Down Expand Up @@ -2567,7 +2567,7 @@ export async function createNodejsBom(path, options) {
).toString();
parsedList.dependenciesList.push({
ref: decodeURIComponent(ppurl),
dependsOn: rdeplist,
dependsOn: [...new Set(rdeplist)].sort(),
});
}
dependencies = mergeDependencies(
Expand Down Expand Up @@ -2855,14 +2855,14 @@ export async function createPythonBom(path, options) {
}
}
if (retMap.rootList) {
const parentDependsOn = [];
const parentDependsOn = new Set();
// Complete the dependency tree by making parent component depend on the first level
for (const p of retMap.rootList) {
parentDependsOn.push(`pkg:pypi/${p.name.toLowerCase()}@${p.version}`);
parentDependsOn.add(`pkg:pypi/${p.name.toLowerCase()}@${p.version}`);
}
const pdependencies = {
ref: parentComponent["bom-ref"],
dependsOn: parentDependsOn,
dependsOn: [...parentDependsOn].sort(),
};
dependencies.splice(0, 0, pdependencies);
}
Expand Down Expand Up @@ -3530,7 +3530,9 @@ export async function createGoBom(path, options) {
const thisParentDependsOn = [
{
ref: retMap.parentComponent["bom-ref"],
dependsOn: retMap.rootList.map((c) => c["bom-ref"]),
dependsOn: [
...new Set(retMap.rootList.map((c) => c["bom-ref"])),
].sort(),
},
];
dependencies = mergeDependencies(
Expand Down Expand Up @@ -4884,13 +4886,11 @@ export function createPHPBom(path, options) {
);
}
// Complete the dependency tree by making parent component depend on the first level
const parentDependsOn = [];
for (const p of retMap.rootList) {
parentDependsOn.push(p["bom-ref"]);
}
const pdependencies = {
ref: parentComponent["bom-ref"],
dependsOn: parentDependsOn,
dependsOn: [
...new Set(retMap.rootList.map((p) => p["bom-ref"])),
].sort(),
};
dependencies = mergeDependencies(
dependencies,
Expand Down Expand Up @@ -4983,7 +4983,7 @@ export async function createRubyBom(path, options) {
[
{
ref: parentComponent["bom-ref"],
dependsOn: rootList,
dependsOn: [...new Set(rootList)].sort(),
},
],
parentComponent,
Expand Down Expand Up @@ -5184,7 +5184,7 @@ export async function createCsharpBom(path, options) {
const dependsOn = dependenciesMap[k].map(
(p) => `pkg:nuget/${p}@${pkgNameVersions[p] || "latest"}`,
);
dependencies.push({ ref: k, dependsOn: dependsOn.sort() });
dependencies.push({ ref: k, dependsOn: [...new Set(dependsOn)].sort() });
}
}
// project.assets.json parsing
Expand Down Expand Up @@ -5360,7 +5360,7 @@ export async function createCsharpBom(path, options) {
if (parentDependsOn.size && parentComponent && parentComponent["bom-ref"]) {
dependencies.splice(0, 0, {
ref: parentComponent["bom-ref"],
dependsOn: Array.from(parentDependsOn),
dependsOn: Array.from(parentDependsOn).sort(),
});
}
if (FETCH_LICENSE) {
Expand Down
Loading

0 comments on commit b89cb4c

Please sign in to comment.