Skip to content

Commit a0fa30e

Browse files
Fix exclude bug
Signed-off-by: Wonjae Park <[email protected]>
1 parent 24baedc commit a0fa30e

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
@@ -256,7 +256,7 @@ def create_report_file(
256256
return scan_item
257257

258258

259-
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}) -> list:
259+
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}, path_to_exclude =[]) -> list:
260260
"""
261261
Merge scanner results and spdx parsing result.
262262
:param scancode_result: list of scancode results in SourceItem.
@@ -281,6 +281,13 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do
281281
scancode_result.append(new_result_item)
282282

283283
for item in scancode_result:
284+
item_path = item.source_name_or_path
285+
if any(
286+
excluded in item_path and
287+
(item_path == excluded or item_path.startswith(f"{excluded}{os.sep}"))
288+
for excluded in path_to_exclude
289+
):
290+
continue
284291
item.set_oss_item()
285292

286293
return scancode_result
@@ -340,7 +347,7 @@ def run_scanners(
340347
path_to_exclude)
341348
if selected_scanner in SCANNER_TYPE:
342349
spdx_downloads = get_spdx_downloads(path_to_scan, path_to_exclude)
343-
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads)
350+
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads, path_to_exclude)
344351
scan_item = create_report_file(start_time, merged_result, license_list, scanoss_result, selected_scanner,
345352
print_matched_text, output_path, output_files, output_extensions, correct_mode,
346353
correct_filepath, path_to_scan, path_to_exclude, formats)

0 commit comments

Comments
 (0)