Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scanpipe/pipes/d2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from pathlib import Path
from timeit import default_timer as timer

from django.db.models import Q

from scanpipe import pipes
from scanpipe.models import CodebaseRelation
from scanpipe.models import CodebaseResource
Expand Down Expand Up @@ -614,12 +616,23 @@ def _map_about_file_resource(project, about_file_resource, to_resources):
# Cannot map anything without the about_resource value.
return

ignored_resources = []
if extra_data := package_data.get("extra_data"):
ignored_resources = extra_data.get("ignored_resources")

# Fetch all resources that are covered by the .ABOUT file.
codebase_resources = to_resources.filter(path__contains=f"/{filename.lstrip('/')}")
if not codebase_resources:
# If there's nothing to map on the ``to/`` do not create the package.
return

# Ignore resources for paths in `ignored_resources` attribute
if ignored_resources:
lookups = Q()
for resource_path in ignored_resources:
lookups |= Q(**{"path__contains": resource_path})
codebase_resources = codebase_resources.filter(~lookups)

# Create the Package using .ABOUT data and assigned related codebase_resources
pipes.update_or_create_package(project, package_data, codebase_resources)

Expand Down
4 changes: 4 additions & 0 deletions scanpipe/pipes/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def resolve_about_package(input_location):
if about_resource := about_data.get("about_resource"):
package_data["filename"] = list(about_resource.keys())[0]

if ignored_resources := about_data.get("ignored_resources"):
extra_data = {"ignored_resources": list(ignored_resources.keys())}
package_data["extra_data"] = extra_data

if license_expression := about_data.get("license_expression"):
package_data["declared_license_expression"] = license_expression

Expand Down
Loading