From e698636af4fe12dfe532d331f3c2067797ae2343 Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Mon, 29 Jun 2015 09:42:40 +0200 Subject: [PATCH 1/2] added test to reproduce #4183 --- .../Package/Archiver/ArchivableFilesFinderTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php index e9233f3cb..3c0c44abe 100644 --- a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php @@ -75,7 +75,8 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase 'parameters.yml', 'parameters.yml.dist', '!important!.txt', - '!important_too!.txt' + '!important_too!.txt', + '#weirdfile', ); foreach ($fileTree as $relativePath) { @@ -98,7 +99,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase '!/prefixB.foo', '/prefixA.foo', 'prefixC.*', - '!*/*/*/prefixC.foo' + '!*/*/*/prefixC.foo', ); $this->finder = new ArchivableFilesFinder($this->sources, $excludes); @@ -106,6 +107,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase $this->assertArchivableFiles(array( '/!important!.txt', '/!important_too!.txt', + '/#weirdfile', '/A/prefixA.foo', '/A/prefixD.foo', '/A/prefixE.foo', @@ -170,7 +172,8 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase 'H/**', 'J/', 'parameters.yml', - '\!important!.txt' + '\!important!.txt', + '\#*', ))); // git does not currently support negative git attributes @@ -181,7 +184,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase //'!/prefixB.foo export-ignore', '/prefixA.foo export-ignore', 'prefixC.* export-ignore', - //'!/*/*/prefixC.foo export-ignore' + //'!/*/*/prefixC.foo export-ignore', ))); $this->finder = new ArchivableFilesFinder($this->sources, array()); From 0298cdc60d79bdb041973e0d78d73a061ccf092c Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Tue, 30 Jun 2015 13:51:17 +0200 Subject: [PATCH 2/2] change delimiter to curly braces --- src/Composer/Package/Archiver/BaseExcludeFilter.php | 4 ++-- tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Package/Archiver/BaseExcludeFilter.php b/src/Composer/Package/Archiver/BaseExcludeFilter.php index d724f31e4..c94c52a6b 100644 --- a/src/Composer/Package/Archiver/BaseExcludeFilter.php +++ b/src/Composer/Package/Archiver/BaseExcludeFilter.php @@ -123,7 +123,7 @@ abstract class BaseExcludeFilter protected function generatePattern($rule) { $negate = false; - $pattern = '#'; + $pattern = '{'; if (strlen($rule) && $rule[0] === '!') { $negate = true; @@ -143,6 +143,6 @@ abstract class BaseExcludeFilter // remove delimiters as well as caret (^) and dollar sign ($) from the regex $pattern .= substr(Finder\Glob::toRegex($rule), 2, -2) . '(?=$|/)'; - return array($pattern . '#', $negate, false); + return array($pattern . '}', $negate, false); } } diff --git a/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php b/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php index 97c02c8e6..0a19a1327 100644 --- a/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php +++ b/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php @@ -29,8 +29,8 @@ class GitExcludeFilterTest extends \PHPUnit_Framework_TestCase public function patterns() { return array( - 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(?=$|/)}', false, false)), + array('!app/config/parameters.yml', array('{(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)}', true, false)), ); } }