Support directory paths in referenced_filenames rule attribute#4647
Closed
adityashirsatrao007 wants to merge 1 commit intoaboutcode-org:developfrom
Closed
Conversation
There was a problem hiding this comment.
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_resourceandfind_referenced_resource_from_packageto return lists of Resources instead of single Resources - Added glob pattern support using
fnmatchfor matching multiple files - Added directory support to return all children when a directory path is referenced
- Updated calling code in
update_detection_from_referenced_filesto 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 #4276 Signed-off-by: Aditya <adityashirsatrao007@gmail.com> Signed-off-by: Aditya Shirsatrao <adityashirsatrao007@gmail.com>
f78f365 to
4a9b365
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.