From 44ad86bd9c88c2d10077722d854a69a3c717752a Mon Sep 17 00:00:00 2001 From: andreas hilti Date: Sat, 2 Sep 2023 13:26:06 +0200 Subject: [PATCH] Fix metadata (fix root test) Signed-off-by: andreas hilti --- src/command.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/command.py b/src/command.py index d01acff..cc30b82 100755 --- a/src/command.py +++ b/src/command.py @@ -126,7 +126,7 @@ def execute(self): required_ids = set() if self._arguments.exclude_dev: visited_ids = set() - to_visit: Set[Node] = set(node for node in deps_graph.nodes if node.ref is None) + to_visit: Set[Node] = set(node for node in deps_graph.nodes if not list(node.ancestors)) while to_visit: node = to_visit.pop() if node.id in visited_ids: @@ -138,9 +138,11 @@ def execute(self): to_visit.add(dependency.dst) for node in deps_graph.nodes: - if node.ref is None: + if not list(node.ancestors): # top level component - bom['metadata']['component']['name'] = os.path.basename(os.path.dirname(node.path)) + bom['metadata']['component']['name'] = node.ref.name if node.ref and node.ref.name else os.path.basename(os.path.dirname(node.path)) + if node.ref and node.ref.version: + bom['metadata']['component']['version'] = node.ref.version bom['metadata']['component']['bom-ref'] = bom['metadata']['component']['name'] + '@' + bom['metadata']['component']['version'] dependencies = { 'ref': bom['metadata']['component']['bom-ref'],