-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added support for consecutive asterisks at the beginning or end #20
Conversation
Hi Martins, Thank you for your pull request. I will try to have a closer look later this week. On first glance it looks good, although I'm wondering about the replacement of I see that something has changed in the configuration of Psalm causing the inspections to fail. I will look at that as well. |
* main: Update Psalm and remove deprecated `totallyTyped` attribute
I fixed Psalm in #21 and rebased this PR. I just tried using |
No problem. I will try to look at your pull request before the end of the week. This pull request requires a bit more attention compared to #21. |
Sure, in the mean time I'll use my forked version. 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.
Can you add the suggested test cases to \CodeOwners\Tests\PatternMatcherTest::provideNoMatchFoundExceptionIsThrownForFilename()
? I think your current solution is too forgiving and will result in incorrect results.
src/PatternMatcher.php
Outdated
@@ -62,6 +62,8 @@ private function isMatch(Pattern $pattern, string $filename): bool | |||
'*' => '[^\/]+', | |||
'?' => '[^\/]', | |||
'**' => '.*', | |||
'/**' => '.*', |
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 think we do need to add the slashes. I have created a pull request on a test repository to verify some edge cases. I have added a coworker as codeowner to that repository: https://github.com/timoschinkel/test-repository/pull/6/files
For the rule docs/**
that does apply to docs/file.md
and docs/folder/file.md
, but not to docs.md
.
These situations can be tested by adding the following lines to \CodeOwners\Tests\PatternMatcherTest::provideNoMatchFoundExceptionIsThrownForFilename()
:
// **
[new Pattern('**/foo', ['@owner']), 'foo.ext'],
[new Pattern('foo/**', ['@owner']), 'foo.ext'],
@timoschinkel Updated code as per your suggestions. |
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.
Sorry, but I did find an issue with the **/
pattern. I've supplied a test case and I have verified this with a pull request on GitHub: https://github.com/timoschinkel/test-repository/pull/6/files
If we apply this fix then this change can be merged I think.
Co-authored-by: Timo Schinkel <[email protected]>
@timoschinkel done |
Thank you for the contribution. I just released this in 2.1.0. |
According to CODEOWNERS Syntax doc, CODEOWNERS file uses a pattern that follows most of the same rules used in gitignore files.
This Pull Requests adds support for consecutive asterisks at the beginning or end (
**/foo
,foo/**
). The case where asterisks are in the middle (a/**/b
) was already supported.