Skip to content
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

Are filters ANDed? #45

Closed
billyvg opened this issue Oct 21, 2020 · 1 comment · Fixed by #46
Closed

Are filters ANDed? #45

billyvg opened this issue Oct 21, 2020 · 1 comment · Fixed by #46

Comments

@billyvg
Copy link
Contributor

billyvg commented Oct 21, 2020

Hey, great work on this, I see you've discovered our usage of it at Sentry. We're trying to use a few negation filters together, as an example

backend:
  - '!**/*.tsx'
  - '!**/*.less'

However, this doesn't work as I had expected - it seems to be ORing each filter so if I had a commit where a tsx file changed, backend would still match due to the second filter. Is this expected? Am I writing the filters incorrectly?

@dorny
Copy link
Owner

dorny commented Oct 22, 2020

Yeah I got notification that @getsentry forked the repo. Then I got an idea I could use it as a "real world" usage example in successful project :)

Your findings are correct. Filter evaluates to true if any of the path patterns matches any file - so it's OR.
Solution would be to merge it into one negated pattern:

backend:
  - '!(**/*.tsx|**/*.less)'

Unfortunately I found out minimatch library is not handling this correctly.
I quickly tested it with micromatch and that seems to work.

micromatch claims to support full Bash 4.3 spec and it actually passes all the tests so using it seems to be a good improvement anyway. I will release new version with micromatch in following days and then the '!(**/*.tsx|**/*.less)' pattern should work.

dorny added a commit that referenced this issue Oct 23, 2020
micromatch claims to support full Bash 4.3 spec and it actually passes all the tests. 
For example this fixes processing of '!(**/*.tsx|**/*.less)' pattern - needed by #45
@dorny dorny closed this as completed in #46 Oct 23, 2020
dorny added a commit that referenced this issue Oct 23, 2020
* Use micromatch instead of minimatch

micromatch claims to support full Bash 4.3 spec and it actually passes all the tests. 
For example this fixes processing of '!(**/*.tsx|**/*.less)' pattern - needed by #45

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants