1
0
Fork 0

Also condense dev-* versions if there are many, refs #9850

pull/9864/head
Jordi Boggiano 2021-05-03 14:42:23 +02:00
parent 9b7a8d4543
commit 298246dccb
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 10 additions and 4 deletions

View File

@ -362,7 +362,7 @@ class Problem
* @param string[] $versions an array of pretty versions, with normalized versions as keys
* @return list<string> a list of pretty versions and '...' where versions were removed
*/
private static function condenseVersionList(array $versions, $max)
private static function condenseVersionList(array $versions, $max, $maxDev = 16)
{
if (count($versions) <= $max) {
return $versions;
@ -371,10 +371,16 @@ class Problem
$filtered = array();
$byMajor = array();
foreach ($versions as $version => $pretty) {
$byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
if (0 === stripos($version, 'dev-')) {
$byMajor['dev'][] = $pretty;
} else {
$byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
}
}
foreach ($byMajor as $versionsForMajor) {
if (count($versionsForMajor) > $max) {
foreach ($byMajor as $majorVersion => $versionsForMajor) {
$maxVersions = $majorVersion === 'dev' ? $maxDev : $max;
if (count($versionsForMajor) > $maxVersions) {
// output only 1st and last versions
$filtered[] = $versionsForMajor[0];
$filtered[] = '...';
$filtered[] = $versionsForMajor[count($versionsForMajor) - 1];