1
0
Fork 0

Add a / to the beginning of a file matchin pattern if no / in rule.

See https://www.kernel.org/pub/software/scm/git/docs/gitignore.html
pull/1754/head
Reto Kaiser 2013-04-01 23:04:00 +02:00
parent 83084eedf9
commit 6f72e9570c
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
*
* @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)
{
@ -133,6 +133,8 @@ abstract class BaseExcludeFilter
if (strlen($rule) && $rule[0] === '/') {
$pattern .= '^/';
$rule = substr($rule, 1);
} elseif (false === strpos($rule, '/') || strlen($rule) - 1 === strpos($rule, '/')) {
$pattern .= '/';
}
$pattern .= substr(Finder\Glob::toRegex($rule), 2, -2);

View File

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