1
0
Fork 0

Fix show command output to remove v prefixes on versions, making for more uniform output, fixes #11925

pull/11932/head
Jordi Boggiano 2024-04-15 13:23:25 +02:00
parent 89f057e0df
commit 92f641ac3d
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 16 additions and 10 deletions

View File

@ -535,10 +535,13 @@ EOT
$packageViewData['homepage'] = $package instanceof CompletePackageInterface ? $package->getHomepage() : null;
$packageViewData['source'] = PackageInfo::getViewSourceUrl($package);
}
$nameLength = max($nameLength, strlen($package->getPrettyName()));
$nameLength = max($nameLength, strlen($packageViewData['name']));
if ($writeVersion) {
$packageViewData['version'] = $package->getFullPrettyVersion();
$versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
if ($format === 'text') {
$packageViewData['version'] = ltrim($packageViewData['version'], 'v');
}
$versionLength = max($versionLength, strlen($packageViewData['version']));
}
if ($writeReleaseDate) {
if ($package->getReleaseDate() !== null) {
@ -553,6 +556,9 @@ EOT
}
if ($writeLatest && $latestPackage) {
$packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
if ($format === 'text') {
$packageViewData['latest'] = ltrim($packageViewData['latest'], 'v');
}
$packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
$latestLength = max($latestLength, strlen($packageViewData['latest']));
} elseif ($writeLatest) {

View File

@ -36,13 +36,13 @@ class ShowCommandTest extends TestCase
'packages' => [
'type' => 'package',
'package' => [
['name' => 'vendor/package', 'description' => 'generic description', 'version' => '1.0.0'],
['name' => 'vendor/package', 'description' => 'generic description', 'version' => 'v1.0.0'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.0.0 description', 'version' => '1.0.0'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.0.1 description', 'version' => '1.0.1'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.1.0 description', 'version' => '1.1.0'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.1.1 description', 'version' => '1.1.1'],
['name' => 'outdated/major', 'description' => 'outdated/major v2.0.0 description', 'version' => '2.0.0'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.0.0 description', 'version' => 'v1.0.0'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.0.1 description', 'version' => 'v1.0.1'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.1.0 description', 'version' => 'v1.1.0'],
['name' => 'outdated/major', 'description' => 'outdated/major v1.1.1 description', 'version' => 'v1.1.1'],
['name' => 'outdated/major', 'description' => 'outdated/major v2.0.0 description', 'version' => 'v2.0.0'],
['name' => 'outdated/minor', 'description' => 'outdated/minor v1.0.0 description', 'version' => '1.0.0'],
['name' => 'outdated/minor', 'description' => 'outdated/minor v1.0.1 description', 'version' => '1.0.1'],
@ -57,9 +57,9 @@ class ShowCommandTest extends TestCase
'require' => $requires === [] ? new \stdClass : $requires,
]);
$pkg = self::getPackage('vendor/package', '1.0.0');
$pkg = self::getPackage('vendor/package', 'v1.0.0');
$pkg->setDescription('description of installed package');
$major = self::getPackage('outdated/major', '1.0.0');
$major = self::getPackage('outdated/major', 'v1.0.0');
$major->setReleaseDate(new DateTimeImmutable());
$minor = self::getPackage('outdated/minor', '1.0.0');
$minor->setReleaseDate(new DateTimeImmutable('-2 years'));