-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
Fix regression in ignoring symlinks #23535
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d348d76
Fix regression in ignoring symlinks
ianbuss 6a0d878
Fix static checks
ianbuss 7d150b2
Add rudimentary infinite recursion detection and migrate to pytest
ianbuss 67212ee
Use pytest tmp_path fixture
ianbuss 40d1e2c
Undo config changes, minor updates to formatting, remove unnecessary log
ianbuss 9cced24
Fix flake8 issues
ianbuss fd14285
Address a couple more static check issues
ianbuss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
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.
Where is this called? (There are too many things called
match
I have difficulties locating the call sites.)relative_to
is sensitive to whether the incoming path is absolute or not, so this might not work as intended if this is called against a wrong value.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.
In
def _find_path_from_directory(
I think (as a defensive programming method), I'd call .resolve() also here:
Also it would be great to refactor the
path
file name to "abs_path" and make sure everywhere it is used to be sure that we are using abs paths where we intend to.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.
I generally prefer to change all the paths to "absolute" as early as possible and only use the absolute ones wherever I can (and derive relative paths when needed, knowing that all the paths I might get are always absolute (and be explicit about it).
That enormously helps with lowering the mental effort needed to read and understand what's going on - the "relative" paths require you to also know (sometimes you have to know it out of a thin air) what they are relative to.
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.
Yes, the
match
method of theIgnoreRule
implementations is called in the snippet @potiuk shared @uranusjr. I would also like to be defensive @potiuk and that is essentially what we had before this change. Unfortunately though, we cannot callresolve
as it will normalise-away the symlink elements in the path, which will result in user's patterns not matching when they should.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.
Couldn't agree more, although some extra complexity here is in play here due to the use of relative patterns in the ignore files. I'll go over the code again to see if there are opportunities to simplify further. I will definitely change the variable names to
abs_path
here though to reduce the cognitive load.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.
Ah yeah... 🤦 - the whole point here was to ignore symlinks rather than what they resolve to.