diff --git a/ChangeLog.md b/ChangeLog.md index 35a91c0..4f638c3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,7 @@ ## NEXT * `bom show` now also shows the group, if it exists. +* Fix issue in `project prerequisites` when reading an empty project. ## 2.10.0 diff --git a/capycli/project/check_prerequisites.py b/capycli/project/check_prerequisites.py index 550bdcd..a6c37e9 100644 --- a/capycli/project/check_prerequisites.py +++ b/capycli/project/check_prerequisites.py @@ -155,6 +155,7 @@ def check_project_prerequisites(self, id: str, sbom: Optional[Bom]) -> bool: else: print_text("\n No linked projects") + releases: List[Dict[str, Any]] = [] if "sw360:releases" in project["_embedded"]: print_text("\n Components: ") releases = project["_embedded"]["sw360:releases"] @@ -162,7 +163,7 @@ def check_project_prerequisites(self, id: str, sbom: Optional[Bom]) -> bool: href = key["_links"]["self"]["href"] release = self.client.get_release_by_url(href) if not release: - print_red("Error accessign release " + href) + print_red("Error accessing release " + href) count_errors += 1 continue @@ -267,7 +268,10 @@ def check_project_prerequisites(self, id: str, sbom: Optional[Bom]) -> bool: print_text(" No linked releases") print_text("\nSummary:") - print_text(" Total components: " + str(len(releases))) + if releases: + print_text(" Total components: " + str(len(releases))) + else: + print_text(" Total components: 0 (no releases)") if count_warnings > 0: print_yellow(" Warnings: " + str(count_warnings)) if count_errors > 0: diff --git a/tests/test_get_dependencies_rust.py b/tests/test_get_dependencies_rust.py index 44c59d6..65289cd 100644 --- a/tests/test_get_dependencies_rust.py +++ b/tests/test_get_dependencies_rust.py @@ -7,8 +7,8 @@ # ------------------------------------------------------------------------------- import os -import pytest +import pytest import responses # from capycli.common import json_support