Skip to content

Commit 3ffd213

Browse files
bumping: fix root element to include DESCRIBED elements
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
1 parent 55c6386 commit 3ffd213

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/spdx_tools/spdx3/bump_from_spdx2/creation_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def bump_creation_info(spdx2_creation_info: Spdx2_CreationInfo, payload: Payload
7070
name=spdx2_creation_info.name,
7171
comment=spdx2_creation_info.document_comment,
7272
element=[],
73-
root_element=[spdx_id],
73+
root_element=[],
7474
imports=imports,
7575
namespaces=namespaces,
7676
)

src/spdx_tools/spdx3/bump_from_spdx2/spdx_document.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from spdx_tools.spdx3.bump_from_spdx2.snippet import bump_snippet
1010
from spdx_tools.spdx3.model import CreationInfo, SpdxDocument
1111
from spdx_tools.spdx3.payload import Payload
12+
from spdx_tools.spdx.model import RelationshipType
1213
from spdx_tools.spdx.model.document import Document as Spdx2_Document
14+
from spdx_tools.spdx.model.relationship_filters import filter_by_type_and_origin
1315

1416
""" We want to implement a bump_from_spdx2 from the data model in src.spdx to the data model in src.spdx3.
1517
As there are many fundamental differences between these version we want each bump_from_spdx2 method to take
@@ -20,6 +22,13 @@ def bump_spdx_document(document: Spdx2_Document) -> Payload:
2022
payload = Payload()
2123
document_namespace: str = document.creation_info.document_namespace
2224
spdx_document: SpdxDocument = bump_creation_info(document.creation_info, payload)
25+
spdx_document.root_element = [
26+
f"{document_namespace}#{relationship.related_spdx_element_id}"
27+
for relationship in filter_by_type_and_origin(
28+
document.relationships, RelationshipType.DESCRIBES, "SPDXRef-DOCUMENT"
29+
)
30+
]
31+
2332
creation_info: CreationInfo = spdx_document.creation_info
2433

2534
payload.add_element(spdx_document)

0 commit comments

Comments
 (0)