Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Finder] Glob wildcard while using double-star without ending slash#22239

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@sroze
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsø
LicenseMIT
Doc PRø

This PR allows to use theGlob::toRegex method to dump a glob that will match "everything after" while using the double-star without leading slash./foo/** will therefore match/foo/a or/foo/a/b/c or even/foo/a/b/c/d.e.

The use-case for this change is an application allowing its users to match a list of files/folders from such glob pattern.

Happy to add a line in the CHANGELOG and documentation if you feel that would make sense.

theofidry reacted with thumbs up emoji
$car =$strictLeadingDot ?'/(?:(?=[^\.])[^/]++/)*' :'/(?:[^/]++/)*';
$i +=3;
}elseif (isset($glob[$i +2]) &&'**' ===$glob[$i +1].$glob[$i +2]) {
$car ='/.*';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This should match only at the end of the line - not the case right now.
This should account for hidden "dot-dirs", as done by the regexp L65.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agree with the hidden "dot-dirs". But should it actually match only at the end of the line? I think it'd be better if it can actually match inside the line, don't you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

it already matches inside the line: that's the first case of the "if"
seehttps://github.com/symfony/symfony/pull/22239/files#r109962164

@srozesrozeforce-pushed theglob-double-star-without-leading-slash branch fromd5b703b to94fe26aCompareApril 5, 2017 16:15
@sroze
Copy link
ContributorAuthor

@nicolas-grekas updated the PR and addedthis comment.

$car =$strictLeadingDot ?'/(?:(?=[^\.])[^/]++/)*' :'/(?:[^/]++/)*';
$i +=3;
}elseif (isset($glob[$i +2]) &&'**' ===$glob[$i +1].$glob[$i +2]) {
$car =$strictLeadingDot ?'/(?=[^\.]).*' :'/.*';
Copy link
Member

@nicolas-grekasnicolas-grekasApr 5, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

to me, the rx here should be the same as before, meaning the patch could have just one line:
if ($firstByte && $strictWildcardSlash && isset($glob[$i + 2]) && '**' === $glob[$i + 1].$glob[$i + 2] && (!isset($glob[$i + 3]) || '/' === $glob[$i + 3])) {

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It won't work because of the ending slash in the existing regex.

$i +=3;
}elseif (isset($glob[$i +2]) &&'**' ===$glob[$i +1].$glob[$i +2]) {
$car =$strictLeadingDot ?'/(?=[^\.]).*' :'/.*';
$i +=2;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

well, two:$i += 2 + isset($glob[$i + 3]);

@sroze
Copy link
ContributorAuthor

@nicolas-grekas unfortunately your two-line change wasn't an option because of the/ at the end. I've pushed a refactored version to allow this/ not to be there when just using** without/ after.

$car =$strictLeadingDot ?'/(?:(?=[^\.])[^/]++/)*' :'/(?:[^/]++/)*';
$i +=3;
if ($firstByte &&$strictWildcardSlash &&isset($glob[$i +2]) &&'**' ===$glob[$i +1].$glob[$i +2] && (!isset($glob[$i +3]) ||'/' ===$glob[$i +3])) {
$car ='[^/]++/';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

would that work?
$car = $strictLeadingDot ? '(?:/(?=[^\.])[^/]*+)+' : '(?:/[^/]*+)+'

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nup, it's not. I tried to make it working with a one-liner like that but all my attempts were either not matching "deep children" (level + 1) or matching the folder without its slash (likefoo forfoo/**)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this$car creation is also more readable.

@sroze
Copy link
ContributorAuthor

The built errored on Travis, could someone with super-powers could restart it? :)

@sstok
Copy link
Contributor

Amend your commit and then force push (with the branch name) and should restart Travis 👍

@srozesrozeforce-pushed theglob-double-star-without-leading-slash branch from9c63d42 to2c3ef42CompareApril 9, 2017 09:11
@sroze
Copy link
ContributorAuthor

All green 👍

@srozesroze changed the title[Finder] Glob wildcard while using double-star without leading slash[Finder] Glob wildcard while using double-star without ending slashApr 9, 2017
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍
Status: reviewed

@fabpot
Copy link
Member

Can you add a note in the CHANGELOG?

@sroze
Copy link
ContributorAuthor

@fabpot don't you think that@nicolas-grekas' one already for 3.3.0 is enough?

@fabpot
Copy link
Member

Thank you@sroze.

@srozesroze deleted the glob-double-star-without-leading-slash branchApril 10, 2017 17:55
@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@sroze@sstok@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp