1
0
Fork 0

Update version parser to support any branch name

pull/329/head
Jordi Boggiano 2012-02-18 19:08:44 +01:00
parent ae7107fc22
commit 3e6176eccf
1 changed files with 8 additions and 3 deletions

View File

@ -34,10 +34,15 @@ class VersionParser
{
$version = trim($version);
if (preg_match('{^(?:master|trunk|default)(?:[.-]?dev)?$}i', $version)) {
// match master-like branches
if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) {
return '9999999-dev';
}
if ('dev-' === strtolower(substr($version, 0, 4))) {
return strtolower($version);
}
// match classical versioning
if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?'.$this->modifierRegex.'$}i', $version, $matches)) {
$version = $matches[1]
@ -53,7 +58,7 @@ class VersionParser
// add version modifiers if a version was matched
if (isset($index)) {
if (!empty($matches[$index])) {
$mod = array('{^pl?$}', '{^rc$}');
$mod = array('{^pl?$}i', '{^rc$}i');
$modNormalized = array('patch', 'RC');
$version .= '-'.preg_replace($mod, $modNormalized, strtolower($matches[$index]))
. (!empty($matches[$index+1]) ? $matches[$index+1] : '');
@ -97,7 +102,7 @@ class VersionParser
return str_replace('x', '9999999', $version).'-dev';
}
throw new \UnexpectedValueException('Invalid branch name '.$name);
return 'dev-'.$name;
}
/**