1
0
Fork 0

Bump wildcard constraints to >=current (#11694)

pull/11689/head
Dan Wallis 2023-10-25 17:04:52 +01:00 committed by GitHub
parent c2414c1d17
commit 7a09e05560
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -40,6 +40,7 @@ class VersionBumper
* * ^3@dev + 3.2.99999-dev -> ^3.2@dev
* * ~2 + 2.0-beta.1 -> ~2
* * dev-master + dev-master -> dev-master
* * * + 1.2.3 -> >=1.2.3
*/
public function bumpRequirement(ConstraintInterface $constraint, PackageInterface $package): string
{
@ -86,6 +87,7 @@ class VersionBumper
| ~'.$major.'(?:\.\d+){0,2} # e.g. ~2 or ~2.2 or ~2.2.2 but no more
| '.$major.'(?:\.[*x])+ # e.g. 2.* or 2.*.* or 2.x.x.x etc
| >=\d(?:\.\d+)* # e.g. >=2 or >=1.2 etc
| \* # full wildcard
)
(?=,|$|\ |\||@) # trailing separator
}x';
@ -99,7 +101,7 @@ class VersionBumper
}
if (str_starts_with($match[0], '~') && substr_count($match[0], '.') === 2) {
$replacement = '~'.$versionWithoutSuffix.$suffix;
} elseif (str_starts_with($match[0], '>=')) {
} elseif ($match[0] === '*' || str_starts_with($match[0], '>=')) {
$replacement = '>='.$versionWithoutSuffix.$suffix;
} else {
$replacement = $newPrettyConstraint.$suffix;

View File

@ -67,5 +67,6 @@ class VersionBumperTest extends TestCase
yield 'leave extra-only-tilde alone' => ['~2.2.3.1', '2.2.4.5', '~2.2.3.1'];
yield 'upgrade bigger-or-eq to latest' => ['>=3.0', '3.4.5', '>=3.4.5'];
yield 'leave bigger-than untouched' => ['>2.2.3', '2.2.6', '>2.2.3'];
yield 'upgrade full wildcard to bigger-or-eq' => ['*', '1.2.3', '>=1.2.3'];
}
}