diff --git a/src/Composer/Package/Archiver/BaseExcludeFilter.php b/src/Composer/Package/Archiver/BaseExcludeFilter.php index 90ea53bf8..e52e02af7 100644 --- a/src/Composer/Package/Archiver/BaseExcludeFilter.php +++ b/src/Composer/Package/Archiver/BaseExcludeFilter.php @@ -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); diff --git a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php index 1e780414d..bc5db0c82 100644 --- a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php @@ -113,6 +113,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase 'prefixF.*', '!/*/*/prefixF.foo', '', + 'refixD.foo', ))); // git does not currently support negative git attributes