Merge pull request #9864 from Seldaek/dev-versions-dx
Hint at a branch rename if we detect dev-master can not be found and condense dev-* versions in problem outputpull/9873/head
commit
a04202aa7d
|
@ -291,7 +291,17 @@ class Problem
|
|||
return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'constraint');
|
||||
}
|
||||
|
||||
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match the constraint.');
|
||||
$suffix = '';
|
||||
if ($constraint instanceof Constraint && $constraint->getVersion() === 'dev-master') {
|
||||
foreach ($packages as $candidate) {
|
||||
if (in_array($candidate->getVersion(), array('dev-default', 'dev-main'), true)) {
|
||||
$suffix = ' Perhaps dev-master was renamed to '.$candidate->getPrettyVersion().'?';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match the constraint.' . $suffix);
|
||||
}
|
||||
|
||||
if (!preg_match('{^[A-Za-z0-9_./-]+$}', $packageName)) {
|
||||
|
@ -352,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;
|
||||
|
@ -361,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];
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
--TEST--
|
||||
Test that master branches renamed to main is hinted to the user. This also covers minification of dev-x branches in output.
|
||||
--COMPOSER--
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": [
|
||||
{ "name": "package/a", "version": "2.0.0" },
|
||||
{ "name": "package/a", "version": "2.0.1" },
|
||||
{ "name": "package/a", "version": "2.0.2" },
|
||||
{ "name": "package/a", "version": "2.0.3" },
|
||||
{ "name": "package/a", "version": "2.1.0" },
|
||||
{ "name": "package/a", "version": "2.2.0" },
|
||||
{ "name": "package/a", "version": "2.3.1" },
|
||||
{ "name": "package/a", "version": "2.3.2" },
|
||||
{ "name": "package/a", "version": "2.3.3" },
|
||||
{ "name": "package/a", "version": "2.3.4" },
|
||||
{ "name": "package/a", "version": "2.3.5" },
|
||||
{ "name": "package/a", "version": "2.4.0" },
|
||||
{ "name": "package/a", "version": "2.5.0" },
|
||||
{ "name": "package/a", "version": "2.6.0" },
|
||||
{ "name": "package/a", "version": "dev-main" },
|
||||
{ "name": "package/a", "version": "dev-foo-1" },
|
||||
{ "name": "package/a", "version": "dev-foo-2" },
|
||||
{ "name": "package/a", "version": "dev-foo-3" },
|
||||
{ "name": "package/a", "version": "dev-foo-4" },
|
||||
{ "name": "package/a", "version": "dev-foo-5" },
|
||||
{ "name": "package/a", "version": "dev-foo-6" },
|
||||
{ "name": "package/a", "version": "dev-foo-7" },
|
||||
{ "name": "package/a", "version": "dev-foo-8" },
|
||||
{ "name": "package/a", "version": "dev-foo-9" },
|
||||
{ "name": "package/a", "version": "dev-foo-10" },
|
||||
{ "name": "package/a", "version": "dev-foo-11" },
|
||||
{ "name": "package/a", "version": "dev-foo-12" },
|
||||
{ "name": "package/a", "version": "dev-foo-13" },
|
||||
{ "name": "package/a", "version": "dev-foo-14" },
|
||||
{ "name": "package/a", "version": "dev-foo-15" },
|
||||
{ "name": "package/a", "version": "dev-foo-16" },
|
||||
{ "name": "package/a", "version": "dev-foo-17" },
|
||||
{ "name": "package/a", "version": "dev-foo-18" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"package/a": "dev-master"
|
||||
}
|
||||
}
|
||||
|
||||
--RUN--
|
||||
update
|
||||
|
||||
--EXPECT-EXIT-CODE--
|
||||
2
|
||||
|
||||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies
|
||||
Your requirements could not be resolved to an installable set of packages.
|
||||
|
||||
Problem 1
|
||||
- Root composer.json requires package/a dev-master, found package/a[dev-main, ..., dev-foo-18, 2.0.0, ..., 2.6.0] but it does not match the constraint. Perhaps dev-master was renamed to dev-main?
|
||||
|
||||
--EXPECT--
|
Loading…
Reference in New Issue