1
0
Fork 0

Avoid using the full pretty version for comparisons, fixes #5247

pull/5267/head
Jordi Boggiano 2016-04-26 20:19:54 +01:00
parent 7def8cf6e5
commit 3186b5eeca
1 changed files with 5 additions and 5 deletions

View File

@ -321,7 +321,7 @@ EOT
if ($writeLatest && $latestPackackage) { if ($writeLatest && $latestPackackage) {
$latestVersion = $latestPackackage->getFullPrettyVersion(); $latestVersion = $latestPackackage->getFullPrettyVersion();
$style = $this->getVersionStyle($latestVersion, $package); $style = $this->getVersionStyle($latestPackackage, $package);
$io->write(' <'.$style.'>' . str_pad($latestVersion, $latestLength, ' ') . '</'.$style.'>', false); $io->write(' <'.$style.'>' . str_pad($latestVersion, $latestLength, ' ') . '</'.$style.'>', false);
} }
@ -378,14 +378,14 @@ EOT
); );
} }
protected function getVersionStyle($latestVersion, $package) protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
{ {
if ($latestVersion === $package->getFullPrettyVersion()) { if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
// print green as it's up to date // print green as it's up to date
return 'info'; return 'info';
} }
if ($latestVersion && Semver::satisfies($latestVersion, '^'.$package->getVersion())) { if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), '^'.$package->getVersion())) {
// print red as it needs an immediate semver-compliant upgrade // print red as it needs an immediate semver-compliant upgrade
return 'highlight'; return 'highlight';
} }
@ -455,7 +455,7 @@ EOT
$io->write('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array())); $io->write('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array()));
$this->printVersions($package, $versions, $installedRepo); $this->printVersions($package, $versions, $installedRepo);
if ($latestPackage) { if ($latestPackage) {
$style = $this->getVersionStyle($latestPackage->getPrettyVersion(), $package); $style = $this->getVersionStyle($latestPackage, $package);
$io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>'); $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
} else { } else {
$latestPackage = $package; $latestPackage = $package;