-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve performance by skipping unnecessary normalisation #3751
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aea1c03
Skip some unnecessary normalisation
hauntsaninja 74dd147
lint
hauntsaninja a9d0c07
changelog
hauntsaninja 58cc0ed
comment typo
hauntsaninja cba566d
fix a test
hauntsaninja 7103952
fixing the test broke mypy
hauntsaninja ba5cdec
fixing mypy broke black
hauntsaninja f6e6015
number may be repo specific
hauntsaninja 996770c
remove unnecessary symlink comment
hauntsaninja d017a02
don't recompute relative to root
hauntsaninja bc9b735
Revert "don't recompute relative to root"
hauntsaninja c29a6de
Merge branch 'main' into normalize
hauntsaninja 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
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.
Is it? Looks like we check all entries either way.
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 might be being really dumb, but I think it is, because of the break on L285 / L292. You can hit that in the case of symlinks.
I also think it's maybe a little questionable to be applying gitignore to the resolved file rather than the symlink when formatting the symlink (e.g. a gitignored symlink can now affect what gets formatted), but whatever.
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.
OK I stared at the code some more and this does make sense now. (I thought it mattered only for broken symlinks, but that's not the case.)
We pass a dict here that gets built separately for every directory, since we look for
.gitignore
in every directory, so given a directory structureroot/a/b/c.py
, the dict will containroot/.gitignore
,root/a/.gitignore
,root/a/b/.gitignore
in that order. Thebreak
happens for the first path where the symlink points outside the directory, so it makes sense to ignore all subsequent gitignores as they definitely won't match either.Agree that it probably makes more sense to apply gitignore before resolving symlinks, but that's something do in a separate PR.