-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: Add patterns to ignore files in the reference directory #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 721 800 +79
Branches 119 133 +14
=========================================
+ Hits 721 800 +79
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this 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 adds functionality to ignore specified files in the reference directory during tree comparison by introducing an ignore_patterns parameter to the compare_trees function. This addresses cases where reference directories contain temporary or unwanted files that should be excluded from comparison.
- Added
ignore_patternsparameter tocompare_treesfunction for filtering files using regex patterns - Implemented pattern matching logic to skip files that match any of the ignore patterns
- Added comprehensive test coverage for the new ignore functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dir_content_diff/init.py | Added ignore_patterns parameter and filtering logic to compare_trees function |
| tests/test_base.py | Added test case to verify ignore patterns functionality works correctly |
| README.md | Updated documentation with example usage of the new ignore_patterns feature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@liborjelinek could you test that this branch fixes your issue please? |
03ec575 to
2bdfc42
Compare
|
Hi @liborjelinek !
I think this should cover most cases regarding file selection. Again, if you have some time to test this branch it would be nice, but if you can't it's no big deal and I will merge in a few days. |
d1aaf1a to
d1be2a7
Compare
|
I have now tried But how does it work if both params are passed? Honestly, I can't find a use case for |
|
Great, thanks for your feedback! config = ComparisonConfig(
include_patterns=[r".*\.(py|json|toml|yaml)$"],
exclude_patterns=[
r".*__pycache__.*",
r".*/\.pytest_cache/.*",
]
)to compare Python projects (keeping files with specific extensions but excluding the ones located in specific subdirectories). It would be possible to convert this case with only excluding patterns but I think it would be more complicated because it would require to use a NOT operator in the patterns, which I find a bit ugly. |
|
This feature is included in the new release 1.13.0. |
Description
In some cases the reference directory can be 'dirty', i.e. it can contain files that should not be compared (e.g. *.pyc files or other tmp files). This PR adds a new parameter to
compare_treesto ignore these files.Fixes: #84
Checklist
This pull request is:
Fixes: #<issue number>in the description if it solves an existing issue(which must include a complete example of the issue).
mainbranch and pass with the provided fix.Fixes: #<issue number>in the description if it solves an existing issue(which must include a complete example of the feature).