1
0
Fork 0

Merge branch '1.5'

pull/6706/merge
Jordi Boggiano 2017-11-03 19:53:36 +01:00
commit 26a50b3762
5 changed files with 70 additions and 11 deletions

View File

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

View File

@ -12,6 +12,7 @@
namespace Composer\Package\Version; namespace Composer\Package\Version;
use Composer\Repository\PlatformRepository;
use Composer\Semver\VersionParser as SemverVersionParser; use Composer\Semver\VersionParser as SemverVersionParser;
class VersionParser extends SemverVersionParser class VersionParser extends SemverVersionParser
@ -47,7 +48,7 @@ class VersionParser extends SemverVersionParser
for ($i = 0, $count = count($pairs); $i < $count; $i++) { for ($i = 0, $count = count($pairs); $i < $count; $i++) {
$pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$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]; $pair .= ' '.$pairs[$i + 1];
$i++; $i++;
} }

View File

@ -195,6 +195,22 @@ class RemoteFilesystem
$originUrl = 'github.com'; $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->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
$this->bytesMax = 0; $this->bytesMax = 0;
$this->originUrl = $originUrl; $this->originUrl = $originUrl;

View File

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

View File

@ -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'))),
);
}
}