Skip to content

Commit 6ffe719

Browse files
Fix exclude bug
Signed-off-by: Wonjae Park <[email protected]>
1 parent 9d38ef5 commit 6ffe719

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/fosslight_source/cli.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def create_report_file(
261261
return scan_item
262262

263263

264-
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}) -> list:
264+
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}, path_to_exclude =[]) -> list:
265265
"""
266266
Merge scanner results and spdx parsing result.
267267
:param scancode_result: list of scancode results in SourceItem.
@@ -286,6 +286,13 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do
286286
scancode_result.append(new_result_item)
287287

288288
for item in scancode_result:
289+
item_path = item.source_name_or_path
290+
if any(
291+
excluded in item_path and
292+
(item_path == excluded or item_path.startswith(f"{excluded}{os.sep}"))
293+
for excluded in path_to_exclude
294+
):
295+
continue
289296
item.set_oss_item()
290297

291298
return scancode_result
@@ -345,7 +352,7 @@ def run_scanners(
345352
path_to_exclude)
346353
if selected_scanner in SCANNER_TYPE:
347354
spdx_downloads = get_spdx_downloads(path_to_scan, path_to_exclude)
348-
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads)
355+
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads, path_to_exclude)
349356
scan_item = create_report_file(start_time, merged_result, license_list, scanoss_result, selected_scanner,
350357
print_matched_text, output_path, output_files, output_extensions, correct_mode,
351358
correct_filepath, path_to_scan, path_to_exclude, formats)

0 commit comments

Comments
 (0)