浏览代码

Merge branch '1.5'

Jordi Boggiano 7 年之前
父节点
当前提交
26a50b3762

+ 6 - 1
src/Composer/Command/ShowCommand.php

@@ -43,6 +43,7 @@ use Composer\Semver\Semver;
  * @author Robert Schönthal <seroscho@googlemail.com>
  * @author Jordi Boggiano <j.boggiano@seld.be>
  * @author Jérémy Romey <jeremyFreeAgent>
+ * @author Mihai Plasoianu <mihai@plasoianu.de>
  */
 class ShowCommand extends BaseCommand
 {
@@ -196,9 +197,13 @@ EOT
                 $this->displayPackageTree($package, $installedRepo, $repos);
             } else {
                 $latestPackage = null;
+                $exitCode = 0;
                 if ($input->getOption('latest')) {
                     $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion);
                 }
+                if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) {
+                    $exitCode = 1;
+                }
                 $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
                 $this->printLinks($package, 'requires');
                 $this->printLinks($package, 'devRequires', 'requires (dev)');
@@ -213,7 +218,7 @@ EOT
                 $this->printLinks($package, 'replaces');
             }
 
-            return;
+            return $exitCode;
         }
 
         // show tree view if requested

+ 2 - 1
src/Composer/Package/Version/VersionParser.php

@@ -12,6 +12,7 @@
 
 namespace Composer\Package\Version;
 
+use Composer\Repository\PlatformRepository;
 use Composer\Semver\VersionParser as SemverVersionParser;
 
 class VersionParser extends SemverVersionParser
@@ -47,7 +48,7 @@ class VersionParser extends SemverVersionParser
 
         for ($i = 0, $count = count($pairs); $i < $count; $i++) {
             $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
-            if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/')) {
+            if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $pairs[$i + 1])) {
                 $pair .= ' '.$pairs[$i + 1];
                 $i++;
             }

+ 16 - 0
src/Composer/Util/RemoteFilesystem.php

@@ -195,6 +195,22 @@ class RemoteFilesystem
             $originUrl = 'github.com';
         }
 
+        // Gitlab can be installed in a non-root context (i.e. gitlab.com/foo). When downloading archives the originUrl
+        // is the host without the path, so we look for the registered gitlab-domains matching the host here
+        if (
+            is_array($this->config->get('gitlab-domains'))
+            && false === strpos($originUrl, '/')
+            && !in_array($originUrl, $this->config->get('gitlab-domains'))
+        ) {
+            foreach ($this->config->get('gitlab-domains') as $gitlabDomain) {
+                if (0 === strpos($gitlabDomain, $originUrl)) {
+                    $originUrl = $gitlabDomain;
+                    break;
+                }
+            }
+            unset($gitlabDomain);
+        }
+
         $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
         $this->bytesMax = 0;
         $this->originUrl = $originUrl;

+ 9 - 9
src/Composer/XdebugHandler.php

@@ -139,11 +139,6 @@ class XdebugHandler
         $iniPaths = IniHelper::getAll();
         $additional = count($iniPaths) > 1;
 
-        if (empty($iniPaths[0])) {
-            // There is no loaded ini
-            array_shift($iniPaths);
-        }
-
         if ($this->writeTmpIni($iniPaths)) {
             return $this->setEnvironment($additional, $iniPaths);
         }
@@ -156,20 +151,25 @@ class XdebugHandler
      *
      * The filename is passed as the -c option when the process restarts.
      *
-     * @param array $iniFiles The php.ini locations
+     * @param array $iniPaths Locations reported by the current process
      *
      * @return bool
      */
-    private function writeTmpIni(array $iniFiles)
+    private function writeTmpIni(array $iniPaths)
     {
         if (!$this->tmpIni = tempnam(sys_get_temp_dir(), '')) {
             return false;
         }
 
+        // $iniPaths has at least one item and it may be empty
+        if (empty($iniPaths[0])) {
+            array_shift($iniPaths);
+        }
+
         $content = '';
         $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
 
-        foreach ($iniFiles as $file) {
+        foreach ($iniPaths as $file) {
             $data = preg_replace($regex, ';$1', file_get_contents($file));
             $content .= $data.PHP_EOL;
         }
@@ -203,7 +203,7 @@ class XdebugHandler
      * Returns true if the restart environment variables were set
      *
      * @param bool  $additional Whether there were additional inis
-     * @param array $iniPaths   Locations used by the current prcoess
+     * @param array $iniPaths Locations reported by the current process
      *
      * @return bool
      */

+ 37 - 0
tests/Composer/Test/Package/Version/VersionParserTest.php

@@ -0,0 +1,37 @@
+<?php
+
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ *     Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Test\Package\Version;
+
+use Composer\Package\Version\VersionParser;
+
+class VersionParserTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @dataProvider getParseNameVersionPairsData
+     */
+    public function testParseNameVersionPairs($pairs, $result)
+    {
+        $versionParser = new VersionParser();
+
+        $this->assertSame($result, $versionParser->parseNameVersionPairs($pairs));
+    }
+
+    public function getParseNameVersionPairsData()
+    {
+        return array(
+            array(array('php:^7.0'), array(array('name' => 'php', 'version' => '^7.0'))),
+            array(array('php', '^7.0'), array(array('name' => 'php', 'version' => '^7.0'))),
+            array(array('php', 'ext-apcu'), array(array('name' => 'php'), array('name' => 'ext-apcu'))),
+        );
+    }
+}