Merge remote-tracking branch 'simensen/less-than-dev'

main
Jordi Boggiano 12 years ago
commit 44c271a477

@ -25,7 +25,7 @@ use Composer\Package\LinkConstraint\VersionConstraint;
*/ */
class VersionParser class VersionParser
{ {
private static $modifierRegex = '[._-]?(?:(beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
/** /**
* Returns the stability of a version * Returns the stability of a version
@ -121,6 +121,9 @@ class VersionParser
// add version modifiers if a version was matched // add version modifiers if a version was matched
if (isset($index)) { if (isset($index)) {
if (!empty($matches[$index])) { if (!empty($matches[$index])) {
if ('stable' === $matches[$index]) {
return $version;
}
$mod = array('{^pl?$}i', '{^rc$}i'); $mod = array('{^pl?$}i', '{^rc$}i');
$modNormalized = array('patch', 'RC'); $modNormalized = array('patch', 'RC');
$version .= '-'.preg_replace($mod, $modNormalized, strtolower($matches[$index])) $version .= '-'.preg_replace($mod, $modNormalized, strtolower($matches[$index]))
@ -283,6 +286,10 @@ class VersionParser
if (!empty($stabilityModifier) && $this->parseStability($version) === 'stable') { if (!empty($stabilityModifier) && $this->parseStability($version) === 'stable') {
$version .= '-' . $stabilityModifier; $version .= '-' . $stabilityModifier;
} elseif ('<' === $matches[1]) {
if (!preg_match('/-stable$/', strtolower($matches[2]))) {
$version .= '-dev';
}
} }
return array(new VersionConstraint($matches[1] ?: '=', $version)); return array(new VersionConstraint($matches[1] ?: '=', $version));

@ -195,7 +195,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
'not equal' => array('<>1.0.0', new VersionConstraint('<>', '1.0.0.0')), 'not equal' => array('<>1.0.0', new VersionConstraint('<>', '1.0.0.0')),
'not equal/2' => array('!=1.0.0', new VersionConstraint('!=', '1.0.0.0')), 'not equal/2' => array('!=1.0.0', new VersionConstraint('!=', '1.0.0.0')),
'greater than' => array('>1.0.0', new VersionConstraint('>', '1.0.0.0')), 'greater than' => array('>1.0.0', new VersionConstraint('>', '1.0.0.0')),
'lesser than' => array('<1.2.3.4', new VersionConstraint('<', '1.2.3.4')), 'lesser than' => array('<1.2.3.4', new VersionConstraint('<', '1.2.3.4-dev')),
'less/eq than' => array('<=1.2.3', new VersionConstraint('<=', '1.2.3.0')), 'less/eq than' => array('<=1.2.3', new VersionConstraint('<=', '1.2.3.0')),
'great/eq than' => array('>=1.2.3', new VersionConstraint('>=', '1.2.3.0')), 'great/eq than' => array('>=1.2.3', new VersionConstraint('>=', '1.2.3.0')),
'equals' => array('=1.2.3', new VersionConstraint('=', '1.2.3.0')), 'equals' => array('=1.2.3', new VersionConstraint('=', '1.2.3.0')),
@ -209,6 +209,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
'regression #550' => array('dev-some-fix', new VersionConstraint('=', 'dev-some-fix')), 'regression #550' => array('dev-some-fix', new VersionConstraint('=', 'dev-some-fix')),
'regression #935' => array('dev-CAPS', new VersionConstraint('=', 'dev-CAPS')), 'regression #935' => array('dev-CAPS', new VersionConstraint('=', 'dev-CAPS')),
'ignores aliases' => array('dev-master as 1.0.0', new VersionConstraint('=', '9999999-dev')), 'ignores aliases' => array('dev-master as 1.0.0', new VersionConstraint('=', '9999999-dev')),
'lesser than override' => array('<1.2.3.4-stable', new VersionConstraint('<', '1.2.3.4')),
); );
} }

Loading…
Cancel
Save