1
0
Fork 0

Merge pull request #1754 from njam/issue-1754

Fix file pattern start matching if no slash
pull/1485/merge
Nils Adermann 2013-04-03 05:45:50 -07:00
commit 57c34033ff
2 changed files with 5 additions and 2 deletions

View File

@ -116,9 +116,9 @@ abstract class BaseExcludeFilter
/** /**
* Generates an exclude pattern for filter() from a gitignore rule * Generates an exclude pattern for filter() from a gitignore rule
* *
* @param string An exclude rule in gitignore syntax * @param string $rule An exclude rule in gitignore syntax
* *
* @param array An exclude pattern * @return array An exclude pattern
*/ */
protected function generatePattern($rule) protected function generatePattern($rule)
{ {
@ -133,6 +133,8 @@ abstract class BaseExcludeFilter
if (strlen($rule) && $rule[0] === '/') { if (strlen($rule) && $rule[0] === '/') {
$pattern .= '^/'; $pattern .= '^/';
$rule = substr($rule, 1); $rule = substr($rule, 1);
} elseif (false === strpos($rule, '/') || strlen($rule) - 1 === strpos($rule, '/')) {
$pattern .= '/';
} }
$pattern .= substr(Finder\Glob::toRegex($rule), 2, -2); $pattern .= substr(Finder\Glob::toRegex($rule), 2, -2);

View File

@ -113,6 +113,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
'prefixF.*', 'prefixF.*',
'!/*/*/prefixF.foo', '!/*/*/prefixF.foo',
'', '',
'refixD.foo',
))); )));
// git does not currently support negative git attributes // git does not currently support negative git attributes