Skip to content

Conversation

@adityashirsatrao007
Copy link

This PR updates 'find_referenced_resource' to support directory paths in 'referenced_filenames', enabling rules to match all files within a referenced directory. This fixes #4276.

Copilot AI review requested due to automatic review settings December 23, 2025 08:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the find_referenced_resource function to support directory paths and glob patterns in the referenced_filenames rule attribute, addressing issue #4276. The function now returns a list of Resources instead of a single Resource to accommodate multiple matches.

Key changes:

  • Modified find_referenced_resource and find_referenced_resource_from_package to return lists of Resources instead of single Resources
  • Added glob pattern support using fnmatch for matching multiple files
  • Added directory support to return all children when a directory path is referenced
  • Updated calling code in update_detection_from_referenced_files to handle list returns

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.

File Description
src/licensedcode/detection.py Updated find_referenced_resource and related functions to support glob patterns and directory paths, changing return type from single Resource to list of Resources
tests/licensedcode/test_plugin_license_detection.py Updated existing tests to expect list returns instead of single Resource objects
tests/licensedcode/test_issue_4276.py Added new test cases for glob pattern matching and directory reference functionality
CHANGELOG.rst Added changelog entry documenting the new feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This change updates find_referenced_resource to return a list of resources matching the referenced path, enabling support for directory paths in referenced_filenames. Explicit support for glob patterns is also verified.

Fixes aboutcode-org#4276

Signed-off-by: Aditya <[email protected]>
Signed-off-by: Aditya Shirsatrao <[email protected]>
@adityashirsatrao007 adityashirsatrao007 force-pushed the allow-directories-in-referenced-filenames branch from f78f365 to 4a9b365 Compare December 23, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support directories in referenced_filenames for rules

1 participant