Determine includes and excludes based on scores#104
Determine includes and excludes based on scores#104schlessera merged 8 commits intowp-cli:masterfrom
Conversation
| $pattern = preg_quote( str_replace( '*', '__wildcard__', $path_or_file ) ); | ||
| $pattern = '/' . str_replace( '__wildcard__', '(.+)', $pattern ) . '$'; | ||
| foreach ( $matchers as $path_or_file ) { | ||
| if ( |
There was a problem hiding this comment.
I'd like to have a short comment here describing what is being checked. Maybe something like this:
| if ( | |
| // Without a wildcard, we can directly check the folder hierarchy. | |
| if ( |
|
|
||
| $root_relative_path = str_replace( static::$dir, '', $file->getPathname() ); | ||
| if ( false !== mb_ereg( $pattern, $root_relative_path ) ) { | ||
| if ( |
There was a problem hiding this comment.
This needs a comment as well. I'm not 100% sure what the reason is for checking both ways, I assume this is done for being overly conservative. This certainly needs an explanation.
There was a problem hiding this comment.
Needed for partial wildcards like this:
Given an include wildcard of: dir/wp-* any directory starting with dir/wp- should always be checked. We're checking if the directory starts with the matcher.
Whereas for normal wildcards the check is the other way around: one/two/three/*.js means that a directory called one should be checked to see if the matcher starts with the directory.
Determine includes and excludes based on scores
Include and exclude matches are based on the strength of the match with:
Can probably use improvement but this should cover the base scenarios.