From 92f4c1fb35a12afd69d98f810ee083a66ba48bff Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 8 Dec 2014 15:52:32 +0000 Subject: [PATCH] Allow and ignore semver build metadata, fixes #2422 --- src/Composer/Package/Version/VersionParser.php | 5 +++++ tests/Composer/Test/Package/Version/VersionParserTest.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 70c3de0e5..2a2c38371 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -103,6 +103,11 @@ class VersionParser $version = $match[1]; } + // ignore build metadata + if (preg_match('{^([^,\s+]+)\+[^\s]+$}', $version, $match)) { + $version = $match[1]; + } + // match master-like branches if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) { return '9999999-dev'; diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index 15db1ef69..88058f6aa 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -110,6 +110,10 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase 'parses arbitrary2' => array('DEV-FOOBAR', 'dev-FOOBAR'), 'parses arbitrary3' => array('dev-feature/foo', 'dev-feature/foo'), 'ignores aliases' => array('dev-master as 1.0.0', '9999999-dev'), + 'semver metadata' => array('dev-master+foo.bar', '9999999-dev'), + 'semver metadata/2' => array('1.0.0-beta.5+foo', '1.0.0.0-beta5'), + 'semver metadata/3' => array('1.0.0+foo', '1.0.0.0'), + 'metadata w/ alias' => array('1.0.0+foo as 2.0', '1.0.0.0'), ); } @@ -131,6 +135,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase 'invalid type' => array('1.0.0-meh'), 'too many bits' => array('1.0.0.0.0'), 'non-dev arbitrary' => array('feature-foo'), + 'metadata w/ space' => array('1.0.0+foo bar'), ); }