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.htmlpull/1754/head
parent
83084eedf9
commit
6f72e9570c
|
@ -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);
|
||||
|
|
|
@ -113,6 +113,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
|||
'prefixF.*',
|
||||
'!/*/*/prefixF.foo',
|
||||
'',
|
||||
'refixD.foo',
|
||||
)));
|
||||
|
||||
// git does not currently support negative git attributes
|
||||
|
|
Loading…
Reference in New Issue