1
0
Fork 0

Merge pull request #3292 from francoispluchino/fix-format-version-parser

Fix invalid version format
pull/3291/merge
Jordi Boggiano 2014-09-22 15:19:53 +01:00
commit 1fff2afa1f
2 changed files with 35 additions and 28 deletions

View File

@ -122,6 +122,12 @@ class VersionParser
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)'.self::$modifierRegex.'$}i', $version, $matches)) { // match date-based versioning
$version = preg_replace('{\D}', '-', $matches[1]);
$index = 2;
} elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?'.self::$modifierRegex.'$}i', $version, $matches)) {
$version = $matches[1]
.(!empty($matches[2]) ? $matches[2] : '.0')
.(!empty($matches[3]) ? $matches[3] : '.0')
.(!empty($matches[4]) ? $matches[4] : '.0');
$index = 5;
}
// add version modifiers if a version was matched

View File

@ -97,6 +97,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
'parses dates w/ .' => array('2010.01.02', '2010-01-02'),
'parses dates w/ -' => array('2010-01-02', '2010-01-02'),
'parses numbers' => array('2010-01-02.5', '2010-01-02-5'),
'parses dates y.m.Y' => array('2010.1.555', '2010.1.555.0'),
'parses datetime' => array('20100102-203040', '20100102-203040'),
'parses dt+number' => array('20100102203040-10', '20100102203040-10'),
'parses dt+patch' => array('20100102-203040-p1', '20100102-203040-patch1'),