diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 590d43068..e90357d04 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -380,7 +380,8 @@ class GitDownloader extends VcsDownloader { // set push url for github projects if (preg_match('{^(?:https?|git)://github.com/([^/]+)/([^/]+?)(?:\.git)?$}', $package->getSourceUrl(), $match)) { - $pushUrl = 'git@github.com:'.$match[1].'/'.$match[2].'.git'; + $protocols = $this->config->get('github-protocols'); + $pushUrl = $protocols[0] === 'git' ? 'git@github.com:'.$match[1].'/'.$match[2].'.git' : $package->getSourceUrl(); $cmd = sprintf('git remote set-url --push origin %s', escapeshellarg($pushUrl)); $this->process->execute($cmd, $ignoredOutput, $path); } diff --git a/src/Composer/Repository/ArtifactRepository.php b/src/Composer/Repository/ArtifactRepository.php index 7910d62f7..869e4757f 100644 --- a/src/Composer/Repository/ArtifactRepository.php +++ b/src/Composer/Repository/ArtifactRepository.php @@ -47,7 +47,11 @@ class ArtifactRepository extends ArrayRepository private function scanDirectory($path) { $io = $this->io; - foreach (new \RecursiveDirectoryIterator($path) as $file) { + + $directory = new \RecursiveDirectoryIterator($path); + $iterator = new \RecursiveIteratorIterator($directory); + $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar)$/i'); + foreach ($regex as $file) { /* @var $file \SplFileInfo */ if (!$file->isFile()) { continue; diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 842a8d3f0..a01a422dd 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -137,7 +137,19 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase $downloader->download($packageMock, 'composerPath'); } - public function testDownloadUsesCustomVariousProtocolsForGithub() + public function pushUrlProvider() + { + return array( + array('git', 'git@github.com:composer/composer.git'), + array('https', 'https://github.com/composer/composer'), + array('http', 'https://github.com/composer/composer') + ); + } + + /** + * @dataProvider pushUrlProvider + */ + public function testDownloadAndSetPushUrlUseCustomVariousProtocolsForGithub($protocol, $pushUrl) { $packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock->expects($this->any()) @@ -151,18 +163,24 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('1.0.0')); $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); - $expectedGitCommand = $this->winCompat("git clone 'http://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'http://github.com/composer/composer' && git fetch composer"); + $expectedGitCommand = $this->winCompat("git clone '{$protocol}://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer '{$protocol}://github.com/composer/composer' && git fetch composer"); $processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($expectedGitCommand)) ->will($this->returnValue(0)); + $expectedGitCommand = $this->winCompat("git remote set-url --push origin '{$pushUrl}'"); + $processExecutor->expects($this->at(1)) + ->method('execute') + ->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath'))) + ->will($this->returnValue(0)); + $processExecutor->expects($this->exactly(4)) ->method('execute') ->will($this->returnValue(0)); $config = new Config(); - $config->merge(array('config' => array('github-protocols' => array('http')))); + $config->merge(array('config' => array('github-protocols' => array($protocol)))); $downloader = $this->getDownloaderMock(null, $config, $processExecutor); $downloader->download($packageMock, 'composerPath'); diff --git a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php index ac1bcbbe4..5ffae515a 100644 --- a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php +++ b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php @@ -25,6 +25,7 @@ class ArtifactRepositoryTest extends TestCase 'vendor0/package0-0.0.1', 'composer/composer-1.0.0-alpha6', 'vendor1/package2-4.3.2', + 'vendor3/package1-5.4.3', ); $coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts'); diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/not-an-artifact.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/not-an-artifact.zip new file mode 100644 index 000000000..3e788dcc2 Binary files /dev/null and b/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/not-an-artifact.zip differ diff --git a/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/package1.zip b/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/package1.zip new file mode 100644 index 000000000..a2d96c387 Binary files /dev/null and b/tests/Composer/Test/Repository/Fixtures/artifacts/subfolder/package1.zip differ