diff --git a/doc/05-repositories.md b/doc/05-repositories.md index 2cd0af19b..e79a7767f 100644 --- a/doc/05-repositories.md +++ b/doc/05-repositories.md @@ -229,22 +229,18 @@ In this case the short name of the channel is `pear2`, so the It is possible to alias all pear channel packages with custom name. Example: - You own private pear repository and going to use composer abilities to bring - dependencies from vcs or transit to composer repository scheme. - List of packages: +You own private pear repository and going to use composer abilities to bring dependencies from vcs or transit to composer repository scheme. +Your repository list of packages: * BasePackage, requires nothing * IntermediatePackage, depends on BasePackage * TopLevelPackage1 and TopLevelPackage2 both dependth on IntermediatePackage. - For composer it looks like: + +For composer it looks like: * "pear-pear.foobar.repo/IntermediatePackage" depends on "pear-pear.foobar.repo/BasePackage", * "pear-pear.foobar.repo/TopLevelPackage1" depends on "pear-pear.foobar.repo/IntermediatePackage", * "pear-pear.foobar.repo/TopLevelPackage2" depends on "pear-pear.foobar.repo/IntermediatePackage" - When you update one of your packages to composer naming scheme or made it - available through vcs your older dependencies would not see new version cause it would be named - like "foobar/IntermediatePackage". - Specifying 'vendor-alias' for pear repository you will get all its packages aliased with composer-like names. - Following example would take BasePackage, TopLevelPackage1 and TopLevelPackage2 packages from pear repository - and IntermediatePackage from github repository: + +When you update one of your packages to composer naming scheme or made it available through vcs, your older dependencies would not see new version, cause it would be named like "foobar/IntermediatePackage". Specifying 'vendor-alias' for pear repository, you will get all its packages aliased with composer-like names. Following example would take BasePackage, TopLevelPackage1 and TopLevelPackage2 packages from pear repository and IntermediatePackage from github repository: { "repositories": [ diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 9104ce780..8b37e6c0d 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -211,7 +211,7 @@ class Locker } $name = $package->getPrettyName(); - $version = $package->getVersion(); + $version = $package->getPrettyVersion(); if (!$name || !$version) { throw new \LogicException(sprintf( diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index 180ee5584..d5f070549 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -91,9 +91,13 @@ class PearRepository extends ArrayRepository $result = array(); foreach ($channelInfo->getPackages() as $packageDefinition) { foreach ($packageDefinition->getReleases() as $version => $releaseInfo) { - $normalizedVersion = $this->parseVersion($version); - if (!$normalizedVersion) { - continue; // skip packages with unparsable versions + try { + $normalizedVersion = $versionParser->normalize($version); + } catch (\UnexpectedValueException $e) { + if ($this->io->isVerbose()) { + $this->io->write('Could not load '.$packageDefinition->getPackageName().' '.$version.': '.$e->getMessage()); + } + continue; } $composerPackageName = $this->buildComposerPackageName($packageDefinition->getChannelName(), $packageDefinition->getPackageName()); @@ -175,24 +179,4 @@ class PearRepository extends ArrayRepository return "pear-{$channelName}/{$packageName}"; } - - /** - * Softened version parser. - * - * @param string $version - * @return null|string - */ - private function parseVersion($version) - { - if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?}i', $version, $matches)) { - $version = $matches[1] - .(!empty($matches[2]) ? $matches[2] : '.0') - .(!empty($matches[3]) ? $matches[3] : '.0') - .(!empty($matches[4]) ? $matches[4] : '.0'); - - return $version; - } - - return null; - } } diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index 8136651b2..2f93d77e2 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -138,7 +138,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('pkg1')); $package1 ->expects($this->once()) - ->method('getVersion') + ->method('getPrettyVersion') ->will($this->returnValue('1.0.0-beta')); $package2 @@ -147,7 +147,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('pkg2')); $package2 ->expects($this->once()) - ->method('getVersion') + ->method('getPrettyVersion') ->will($this->returnValue('0.1.10')); $json