From 2d49090ffda947b24a909291e3f7aa3e998b007b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 13 Apr 2012 02:35:52 +0200 Subject: [PATCH 1/2] Make sure branches have proper .x suffix so that they can be parsed properly --- src/Composer/Package/Loader/ArrayLoader.php | 2 +- src/Composer/Repository/VcsRepository.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index f3bd0d5b7..b44d6b950 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -151,7 +151,7 @@ class ArrayLoader } $package->setAlias($validatedTargetBranch); - $package->setPrettyAlias($targetBranch); + $package->setPrettyAlias(preg_replace('{(\.9{7})+}', '.x', $validatedTargetBranch)); break; } } diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 00499b5bb..b70e7c09d 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -200,7 +200,7 @@ class VcsRepository extends ArrayRepository if ('dev-' === substr($parsedBranch, 0, 4) || '9999999-dev' === $parsedBranch) { $data['version'] = 'dev-' . $data['version']; } else { - $data['version'] = $data['version'] . '-dev'; + $data['version'] = preg_replace('{(\.9{7})+}', '.x', $parsedBranch); } if ($verbose) { From 595182aec08c400419b66bed872363327318bdaa Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 13 Apr 2012 02:47:55 +0200 Subject: [PATCH 2/2] Add/fix tests --- src/Composer/Package/Version/VersionParser.php | 1 + tests/Composer/Test/Package/Version/VersionParserTest.php | 1 + tests/Composer/Test/Repository/VcsRepositoryTest.php | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 0329514d5..57d0596cc 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -87,6 +87,7 @@ class VersionParser return $version; } + // match dev branches if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) { try { return $this->normalizeBranch($match[1]); diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index 26cceced6..fa123e7dc 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -51,6 +51,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase 'parses dt+patch' => array('20100102-203040-p1', '20100102-203040-patch1'), 'parses master' => array('dev-master', '9999999-dev'), 'parses trunk' => array('dev-trunk', '9999999-dev'), + 'parses branches' => array('1.x-dev', '1.9999999.9999999.9999999-dev'), 'parses arbitrary' => array('dev-feature-foo', 'dev-feature-foo'), 'parses arbitrary2' => array('DEV-FOOBAR', 'dev-foobar'), 'ignores aliases' => array('dev-master as 1.0.0', '1.0.0.0'), diff --git a/tests/Composer/Test/Repository/VcsRepositoryTest.php b/tests/Composer/Test/Repository/VcsRepositoryTest.php index 7c008f24f..9c09db0a2 100644 --- a/tests/Composer/Test/Repository/VcsRepositoryTest.php +++ b/tests/Composer/Test/Repository/VcsRepositoryTest.php @@ -87,7 +87,7 @@ class VcsRepositoryTest extends \PHPUnit_Framework_TestCase $process->execute('git branch 1.0', $null); // add 1.0.x branch - $process->execute('git branch 1.0.x', $null); + $process->execute('git branch 1.1.x', $null); // update master to 2.0 $composer['version'] = '2.0.0'; @@ -116,8 +116,8 @@ class VcsRepositoryTest extends \PHPUnit_Framework_TestCase $expected = array( '0.6.0' => true, '1.0.0' => true, - '1.0-dev' => true, '1.0.x-dev' => true, + '1.1.x-dev' => true, 'dev-feature-b' => true, 'dev-feature-a' => true, 'dev-master' => true,