fix: match ignore-paths against a symlink's own name - #832
Open
Sanjays2402 wants to merge 1 commit into
Open
Conversation
Adding a symlink's name to ignore-paths/ignore-patterns had no effect; the user had to name the symlink's target instead. make_exclusion_filter called path.resolve() before matching, which dereferences the link, so the name the user actually sees never reached the patterns. The filter now builds both candidates - the path as given and its resolved target, each made relative to the workdir where applicable - and matches the ignore patterns against both. Adds test_symlinked_ignore_path in tests/config/test_config.py, which fails on the unpatched filter and passes with the fix. Closes prospector-dev#608
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.
Closes #608
Description
make_exclusion_filtercalledpath.resolve()before matching the ignorepatterns, which dereferences symlinks. As a result a symlink could only be
excluded by naming its target, never by the link name the user actually sees
in the tree. The filter now matches against both the path as given and its
resolved target (each made relative to the workdir where applicable).
Related Issue
#608 — "[BUG] ignore-paths/patterns do not work with symbolic link names"
Motivation and Context
Adding a symlink's name to
ignore-pathsorignore-patternssilently didnothing, so the linted file set included directories the user had explicitly
excluded. Matching the link name is what the configuration reads as, and the
target is still matched too, so existing configurations keep working.
How Has This Been Tested?
Added
test_symlinked_ignore_pathtotests/config/test_config.py. It createsa directory, a symlink to it, and a profile with
ignore-paths: [link], thenasserts the filter excludes the symlink and a file under it. The test fails on
the unpatched filter (
AssertionError: assert False) and passes with the fix.tests/configandtests/finderpass (30 passed);ruff checkandruff formatare unchanged from baseline on the touched files.Types of changes
Checklist: