Merge pull request #120 from Seldaek/pretty

Use pretty name/version in lock file and debug:packages, fixes #98
main
Nils Adermann 13 years ago
commit 1456a157ea

@ -50,12 +50,12 @@ EOT
$installedRepo = new PlatformRepository($localRepo);
foreach ($installedRepo->getPackages() as $package) {
$output->writeln('installed: '.$package->getName().' '.$package->getVersion());
$output->writeln('installed: '.$package->getPrettyName().' '.$package->getPrettyVersion().' ('.$package->getName().' '.$package->getVersion().')');
}
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
foreach ($repository->getPackages() as $package) {
$output->writeln('available: '.$package->getName().' '.$package->getVersion());
$output->writeln('available: '.$package->getPrettyName().' '.$package->getPrettyVersion().' ('.$package->getName().' '.$package->getVersion().')');
}
}
}

@ -27,7 +27,6 @@ class ArrayDumper
'names',
'extra',
'installationSource' => 'installation-source',
'version',
'license',
'requires',
'conflicts',
@ -41,6 +40,7 @@ class ArrayDumper
$data = array();
$data['name'] = $package->getPrettyName();
$data['version'] = $package->getPrettyVersion();
if ($package->getTargetDir()) {
$data['target-dir'] = $package->getTargetDir();
}

@ -89,8 +89,8 @@ class Locker
{
$hash = array();
foreach ($packages as $package) {
$name = $package->getName();
$version = $package->getVersion();
$name = $package->getPrettyName();
$version = $package->getPrettyVersion();
if (!$name || !$version) {
throw new \LogicException(sprintf(

@ -13,6 +13,7 @@
namespace Composer\Repository;
use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;
/**
* A repository implementation that simply stores packages in an array
@ -29,6 +30,11 @@ class ArrayRepository implements RepositoryInterface
*/
public function findPackage($name, $version)
{
// normalize version & name
$versionParser = new VersionParser();
$version = $versionParser->normalize($version);
$name = strtolower($name);
foreach ($this->getPackages() as $package) {
if ($name === $package->getName() && $version === $package->getVersion()) {
return $package;

@ -122,20 +122,20 @@ class LockerTest extends \PHPUnit_Framework_TestCase
$package1
->expects($this->once())
->method('getName')
->method('getPrettyName')
->will($this->returnValue('pkg1'));
$package1
->expects($this->once())
->method('getVersion')
->method('getPrettyVersion')
->will($this->returnValue('1.0.0-beta'));
$package2
->expects($this->once())
->method('getName')
->method('getPrettyName')
->will($this->returnValue('pkg2'));
$package2
->expects($this->once())
->method('getVersion')
->method('getPrettyVersion')
->will($this->returnValue('0.1.10'));
$json
@ -159,7 +159,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
$package1 = $this->createPackageMock();
$package1
->expects($this->once())
->method('getName')
->method('getPrettyName')
->will($this->returnValue('pkg1'));
$this->setExpectedException('LogicException');

@ -99,7 +99,7 @@ class FilesystemRepositoryTest extends TestCase
->expects($this->once())
->method('write')
->with(array(
array('name' => 'mypkg', 'type' => 'library', 'names' => array('mypkg'), 'version' => '0.1.10.0')
array('name' => 'mypkg', 'type' => 'library', 'names' => array('mypkg'), 'version' => '0.1.10')
));
$repository->addPackage($this->getPackage('mypkg', '0.1.10'));

Loading…
Cancel
Save