From 3e6176eccf73ac0c89612b0243aa871a6a41299b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 18 Feb 2012 19:08:44 +0100 Subject: [PATCH] Update version parser to support any branch name --- src/Composer/Package/Version/VersionParser.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 7bd941d93..716c24731 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -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; } /**