Merge pull request #4193 from alcohol/fix-gitignore-parsing
Fix #4183 - exclude pattern containing delimiter used throws errorpull/4172/head
commit
05c4911f6c
|
@ -123,7 +123,7 @@ abstract class BaseExcludeFilter
|
||||||
protected function generatePattern($rule)
|
protected function generatePattern($rule)
|
||||||
{
|
{
|
||||||
$negate = false;
|
$negate = false;
|
||||||
$pattern = '#';
|
$pattern = '{';
|
||||||
|
|
||||||
if (strlen($rule) && $rule[0] === '!') {
|
if (strlen($rule) && $rule[0] === '!') {
|
||||||
$negate = true;
|
$negate = true;
|
||||||
|
@ -143,6 +143,6 @@ abstract class BaseExcludeFilter
|
||||||
// remove delimiters as well as caret (^) and dollar sign ($) from the regex
|
// remove delimiters as well as caret (^) and dollar sign ($) from the regex
|
||||||
$pattern .= substr(Finder\Glob::toRegex($rule), 2, -2) . '(?=$|/)';
|
$pattern .= substr(Finder\Glob::toRegex($rule), 2, -2) . '(?=$|/)';
|
||||||
|
|
||||||
return array($pattern . '#', $negate, false);
|
return array($pattern . '}', $negate, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
||||||
'parameters.yml',
|
'parameters.yml',
|
||||||
'parameters.yml.dist',
|
'parameters.yml.dist',
|
||||||
'!important!.txt',
|
'!important!.txt',
|
||||||
'!important_too!.txt'
|
'!important_too!.txt',
|
||||||
|
'#weirdfile',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($fileTree as $relativePath) {
|
foreach ($fileTree as $relativePath) {
|
||||||
|
@ -98,7 +99,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
||||||
'!/prefixB.foo',
|
'!/prefixB.foo',
|
||||||
'/prefixA.foo',
|
'/prefixA.foo',
|
||||||
'prefixC.*',
|
'prefixC.*',
|
||||||
'!*/*/*/prefixC.foo'
|
'!*/*/*/prefixC.foo',
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->finder = new ArchivableFilesFinder($this->sources, $excludes);
|
$this->finder = new ArchivableFilesFinder($this->sources, $excludes);
|
||||||
|
@ -106,6 +107,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertArchivableFiles(array(
|
$this->assertArchivableFiles(array(
|
||||||
'/!important!.txt',
|
'/!important!.txt',
|
||||||
'/!important_too!.txt',
|
'/!important_too!.txt',
|
||||||
|
'/#weirdfile',
|
||||||
'/A/prefixA.foo',
|
'/A/prefixA.foo',
|
||||||
'/A/prefixD.foo',
|
'/A/prefixD.foo',
|
||||||
'/A/prefixE.foo',
|
'/A/prefixE.foo',
|
||||||
|
@ -170,7 +172,8 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
||||||
'H/**',
|
'H/**',
|
||||||
'J/',
|
'J/',
|
||||||
'parameters.yml',
|
'parameters.yml',
|
||||||
'\!important!.txt'
|
'\!important!.txt',
|
||||||
|
'\#*',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
// git does not currently support negative git attributes
|
// git does not currently support negative git attributes
|
||||||
|
@ -181,7 +184,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
||||||
//'!/prefixB.foo export-ignore',
|
//'!/prefixB.foo export-ignore',
|
||||||
'/prefixA.foo export-ignore',
|
'/prefixA.foo export-ignore',
|
||||||
'prefixC.* export-ignore',
|
'prefixC.* export-ignore',
|
||||||
//'!/*/*/prefixC.foo export-ignore'
|
//'!/*/*/prefixC.foo export-ignore',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->finder = new ArchivableFilesFinder($this->sources, array());
|
$this->finder = new ArchivableFilesFinder($this->sources, array());
|
||||||
|
|
|
@ -29,8 +29,8 @@ class GitExcludeFilterTest extends \PHPUnit_Framework_TestCase
|
||||||
public function patterns()
|
public function patterns()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('app/config/parameters.yml', array('#(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)#', false, false)),
|
array('app/config/parameters.yml', array('{(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)}', false, false)),
|
||||||
array('!app/config/parameters.yml', array('#(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)#', true, false)),
|
array('!app/config/parameters.yml', array('{(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)}', true, false)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue