Skip to content

Determine includes and excludes based on scores#104

Merged
schlessera merged 8 commits intowp-cli:masterfrom
herregroen:include-and-exclude-scores
Oct 31, 2018
Merged

Determine includes and excludes based on scores#104
schlessera merged 8 commits intowp-cli:masterfrom
herregroen:include-and-exclude-scores

Conversation

@herregroen
Copy link
Copy Markdown
Contributor

Include and exclude matches are based on the strength of the match with:

  1. path matches
  2. filename matches
  3. regex matches

Can probably use improvement but this should cover the base scenarios.

@schlessera schlessera added the command:i18n-make-pot Related to 'i18n make-pot' command label Oct 30, 2018
$pattern = preg_quote( str_replace( '*', '__wildcard__', $path_or_file ) );
$pattern = '/' . str_replace( '__wildcard__', '(.+)', $pattern ) . '$';
foreach ( $matchers as $path_or_file ) {
if (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd like to have a short comment here describing what is being checked. Maybe something like this:

Suggested change
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 (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

@herregroen herregroen Oct 31, 2018

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:i18n-make-pot Related to 'i18n make-pot' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants