1
0
Fork 0

allow bumping for patch level version constraints fixes #11579 (#11590)

pull/11616/head
ಠ_ಠ 2023-08-31 11:05:49 +02:00 committed by GitHub
parent 1c4ac1c437
commit 1a2bd38764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -83,7 +83,7 @@ class VersionBumper
(?<=,|\ |\||^) # leading separator (?<=,|\ |\||^) # leading separator
(?P<constraint> (?P<constraint>
\^'.$major.'(?:\.\d+)* # e.g. ^2.anything \^'.$major.'(?:\.\d+)* # e.g. ^2.anything
| ~'.$major.'(?:\.\d+)? # e.g. ~2 or ~2.2 but no more | ~'.$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 | '.$major.'(?:\.[*x])+ # e.g. 2.* or 2.*.* or 2.x.x.x etc
| >=\d(?:\.\d+)* # e.g. >=2 or >=1.2 etc | >=\d(?:\.\d+)* # e.g. >=2 or >=1.2 etc
) )
@ -97,7 +97,9 @@ class VersionBumper
if (substr_count($match[0], '.') === 2 && substr_count($versionWithoutSuffix, '.') === 1) { if (substr_count($match[0], '.') === 2 && substr_count($versionWithoutSuffix, '.') === 1) {
$suffix = '.0'; $suffix = '.0';
} }
if (str_starts_with($match[0], '>=')) { if (str_starts_with($match[0], '~') && substr_count($match[0], '.') === 2) {
$replacement = '~'.$versionWithoutSuffix.$suffix;
} elseif (str_starts_with($match[0], '>=')) {
$replacement = '>='.$versionWithoutSuffix.$suffix; $replacement = '>='.$versionWithoutSuffix.$suffix;
} else { } else {
$replacement = $newPrettyConstraint.$suffix; $replacement = $newPrettyConstraint.$suffix;

View File

@ -63,7 +63,8 @@ class VersionBumperTest extends TestCase
yield 'leave minor wildcard alone' => ['2.4.*', '2.4.3', '2.4.*']; yield 'leave minor wildcard alone' => ['2.4.*', '2.4.3', '2.4.*'];
yield 'leave patch wildcard alone' => ['2.4.3.*', '2.4.3.2', '2.4.3.*']; yield 'leave patch wildcard alone' => ['2.4.3.*', '2.4.3.2', '2.4.3.*'];
yield 'upgrade tilde to caret when compatible' => ['~2.2', '2.4.3', '^2.4.3']; yield 'upgrade tilde to caret when compatible' => ['~2.2', '2.4.3', '^2.4.3'];
yield 'leave patch-only-tilde alone' => ['~2.2.3', '2.2.6', '~2.2.3']; yield 'update patch-only-tilde alone' => ['~2.2.3', '2.2.6', '~2.2.6'];
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 '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 'leave bigger-than untouched' => ['>2.2.3', '2.2.6', '>2.2.3'];
} }