glob/fsWalk: early exclusion of non-matching directories #1251
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.
Description of the change
For glob patterns with a fixed prefix, fsWalk will now no longer traverse directories whose contents obviously cannot match, because the directory path doesn't match the fixed prefix of the pattern.
For example, previously, globbing for
.spago/p/tailrec-6.1.0/**/*.purs
would traverse every directory (apart from those in a .gitignore, although in the case of globbing for something in .spago, that's not of much help).Now only directories whose relative path starts with
.spago/p/tailrec-6.1.0
would be recursed into.To determine the longest fixed prefix of a glob pattern, i used the scan function from
picomatch
, which is already a dependency of micromatch.Fix #1243 as per #1243 (comment)
Checklist:
P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊