-
Notifications
You must be signed in to change notification settings - Fork 1.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
C#: Fix glob pattern processing: allow **/
to match empty string
#16895
C#: Fix glob pattern processing: allow **/
to match empty string
#16895
Conversation
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.
LGTM
if (i + 2 < pattern.Length) | ||
{ | ||
// Processing .../**/... | ||
sb.Append("(.*/|)"); |
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 had took look at this a while for parsing it: It is an alternation construct that matches any sequence of characters that ends with /
OR "nothing".
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.
Yes, that's the idea.
sb.Append("(.*/|)"); | ||
i += 3; | ||
} | ||
else |
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.
Do we really need this case?
What about
if (i + 2 < pattern.Length)
{
// Processing .../**/...
sb.Append("(.*/|)");
}
i += 3;
If adding three to the index puts the pointer at the end of the pattern we are parsing then we break out of the loop and append .*
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 this would also work, but I slightly prefer to handle this case explicitly. I think it's going to be easier to understand and maintain going forward.
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.
LGTM!
This PR adjusts the path include/exclude logic to allow
**/
to match an empty string. This means that**/src/
will match the content of thesrc
folder in the root of the repository, while previously it only matchedsrc
folders in subdirectories.