Skip to content

Commit 16c0e65

Browse files
committed
Revert changes to licensing.matches_have_unknown
This was making alpine test fail massively Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 5b6998d commit 16c0e65

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/packagedcode/licensing.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212

1313
import saneyaml
14+
from license_expression import Licensing
1415

1516
from licensedcode.cache import build_spdx_license_expression
1617
from licensedcode.cache import get_cache
@@ -579,13 +580,19 @@ def get_license_expression_from_detection_mappings(
579580
)
580581

581582

582-
def matches_have_unknown(matches):
583+
def matches_have_unknown(matches, licensing=Licensing()):
583584
"""
584585
Return True if any of the LicenseMatch in ``matches`` has an unknown license.
585586
Note that by construction and design, an unknown license must have the word "unknown" in its
586-
license key, so we can shortcut the test with a string check.
587-
"""
588-
return any('unknown' in match.rule.license_expression for match in matches)
587+
license key, but we only care about two specific license keys, and not all license keys.
588+
"""
589+
for match in matches:
590+
exp = match.rule.license_expression_object
591+
if any(
592+
key in ('unknown', 'unknown-spdx')
593+
for key in licensing.license_keys(exp)
594+
):
595+
return True
589596

590597

591598
def get_license_detections_from_matches(matches):

0 commit comments

Comments
 (0)