Skip to content

Commit a2f5335

Browse files
Fix exclude bug
Signed-off-by: Wonjae Park <[email protected]>
1 parent 802ce9a commit a2f5335

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
@@ -258,7 +258,7 @@ def create_report_file(
258258
return scan_item
259259

260260

261-
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}) -> list:
261+
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}, path_to_exclude =[]) -> list:
262262
"""
263263
Merge scanner results and spdx parsing result.
264264
:param scancode_result: list of scancode results in SourceItem.
@@ -283,6 +283,13 @@ def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_do
283283
scancode_result.append(new_result_item)
284284

285285
for item in scancode_result:
286+
item_path = item.source_name_or_path
287+
if any(
288+
excluded in item_path and
289+
(item_path == excluded or item_path.startswith(f"{excluded}{os.sep}"))
290+
for excluded in path_to_exclude
291+
):
292+
continue
286293
item.set_oss_item()
287294

288295
return scancode_result
@@ -342,7 +349,7 @@ def run_scanners(
342349
path_to_exclude)
343350
if selected_scanner in SCANNER_TYPE:
344351
spdx_downloads = get_spdx_downloads(path_to_scan, path_to_exclude)
345-
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads)
352+
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads, path_to_exclude)
346353
scan_item = create_report_file(start_time, merged_result, license_list, scanoss_result, selected_scanner,
347354
print_matched_text, output_path, output_files, output_extensions, correct_mode,
348355
correct_filepath, path_to_scan, path_to_exclude, formats)

0 commit comments

Comments
 (0)