From 00f6c0a44aab7496382f1c5e7afff5b9bcdc863c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 18 Dec 2017 10:35:44 +0100 Subject: [PATCH 1/2] Fix issue when requiring multiple packages once without and once with explicit version, fixes #6859 --- src/Composer/Command/InitCommand.php | 27 ++++++++++++++----------- src/Composer/Command/RequireCommand.php | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 9910843be..67cbba53c 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -40,8 +40,8 @@ class InitCommand extends BaseCommand /** @var array */ private $gitConfig; - /** @var Pool */ - private $pool; + /** @var Pool[] */ + private $pools; /** * {@inheritdoc} @@ -598,12 +598,14 @@ EOT private function getPool(InputInterface $input, $minimumStability = null) { - if (!$this->pool) { - $this->pool = new Pool($minimumStability ?: $this->getMinimumStability($input)); - $this->pool->addRepository($this->getRepos()); + $key = $minimumStability ?: 'default'; + + if (!isset($this->pools[$key])) { + $this->pools[$key] = $pool = new Pool($minimumStability ?: $this->getMinimumStability($input)); + $pool->addRepository($this->getRepos()); } - return $this->pool; + return $this->pools[$key]; } private function getMinimumStability(InputInterface $input) @@ -642,13 +644,14 @@ EOT $package = $versionSelector->findBestCandidate($name, $requiredVersion, $phpVersion, $preferredStability); if (!$package) { + // Check whether the PHP version was the problem + if ($phpVersion && $versionSelector->findBestCandidate($name, $requiredVersion, null, $preferredStability)) { + throw new \InvalidArgumentException(sprintf( + 'Package %s at version %s has a PHP requirement incompatible with your PHP version (%s)', $name, $requiredVersion, $phpVersion + )); + } + // Check whether the required version was the problem if ($requiredVersion && $versionSelector->findBestCandidate($name, null, $phpVersion, $preferredStability)) { - // Check whether the PHP version was the problem - if ($phpVersion && $versionSelector->findBestCandidate($name, null, null, $preferredStability)) { - throw new \InvalidArgumentException(sprintf( - 'Package %s at version %s has a PHP requirement incompatible with your PHP version (%s)', $name, $requiredVersion, $phpVersion - )); - } throw new \InvalidArgumentException(sprintf( 'Could not find package %s in a version matching %s', $name, $requiredVersion )); diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 16ca17332..e30143d8e 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -113,7 +113,7 @@ EOT $preferredStability = $composer->getPackage()->getMinimumStability(); } - $phpVersion = $this->repos->findPackage('php', '*')->getVersion(); + $phpVersion = $this->repos->findPackage('php', '*')->getPrettyVersion(); $requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'), $phpVersion, $preferredStability); $requireKey = $input->getOption('dev') ? 'require-dev' : 'require'; From 512188d21261d2e2e11f0a0b24861f2353d2be11 Mon Sep 17 00:00:00 2001 From: Christian Mayer Date: Mon, 18 Dec 2017 11:11:35 +0100 Subject: [PATCH 2/2] Filter macOS .DS_Store files when detecting github archives, fixes #6784, closes #6785 --- src/Composer/Downloader/ArchiveDownloader.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index cc6b34c2f..1b93724ba 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -148,6 +148,7 @@ abstract class ArchiveDownloader extends FileDownloader $finder = Finder::create() ->ignoreVCS(false) ->ignoreDotFiles(false) + ->notName('.DS_Store') ->depth(0) ->in($dir);