-
Notifications
You must be signed in to change notification settings - Fork 10
[COD-360] fix: fixed parsing of negative ignores and added tests #76
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
9204dec to
18373a1
Compare
18373a1 to
f44852c
Compare
| } | ||
|
|
||
| function searchFiles( | ||
| async function* searchFiles( |
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 learn something new everyday function* cool thanks 😃
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.
It'a generator: instead of returning a value or a promise itself, it returns an async generator so you can then use for (await value of results)...
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.
This really took me some time to get my head around! Great Job it looks good to me!
|
🎉 This PR is included in version 3.5.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
COD-360
What does this PR do?
Our current
.gitignoreparsing doesn't work with negative ignores (!-rules). Long story short, it seems that the library on which we base our glob processing (https://github.com/micromatch/micromatch) is not working as expected.For example, an option we use called
basenameis described as "If set, then patterns without slashes will be matched against the basename of the path if it contains slashes", but in reality it always compares the pattern to the basename of the file, regardless if the pattern has a slash or not. This specific feature was already addressed by someone who wanted to use micromatch to parse.gitignorefiles, and it was briefly fixed in version 3.x, however they since reverted the change and now there is no mention of the tests that should have future-proofed this feature.Another issue is that positive glob matching (i.e. finding all the files matching our filters) and negative glob matching (i.e. excluding files following the .gitignore rules) cannot be unified in a single call to micromatch. Trying to use intersections with negations-of-negations would not work properly due to Set Theory. Therefore we need to first filter based on extension and then again based on ignores.
Where should the reviewer start?
Check implementation of
filterIgnoredFilesandparseFileIgnoresand their occurrences.How should this be manually tested?
SNYK_API_HOST=http://localhost:8080 SNYK_API_KEY=<a deepcode sessionToken from your GitHub account in the snyk org> npm run test