Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Fix metadata (fix root test) #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'],
Expand Down