1
0
Fork 0

removed replace, reinstalling as install

pull/250/head
digitalkaoz 2012-01-23 15:43:42 +01:00
parent 30e89a2402
commit 4d0fae688e
9 changed files with 14 additions and 133 deletions

View File

@ -23,7 +23,7 @@ use Composer\Repository\PlatformRepository;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\DependencyResolver\Operation\ReplaceOperation;
use Composer\DependencyResolver\Operation\InstallOperation;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
@ -135,7 +135,7 @@ EOT
if ('install' === $job['cmd']) {
foreach ($installedRepo->getPackages() as $package ) {
if ($installedRepo->hasPackage($package) && !$package->isPlatform() && !$installationManager->isPackageInstalled($package)) {
$operations[$job['packageName']] = new ReplaceOperation($package, \Composer\DependencyResolver\Solver::RULE_PACKAGE_NOT_EXIST);
$operations[$job['packageName']] = new InstallOperation($package, \Composer\DependencyResolver\Solver::RULE_PACKAGE_NOT_EXIST);
}
if (in_array($job['packageName'], $package->getNames())) {
continue 2;

View File

@ -1,66 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\DependencyResolver\Operation;
use Composer\Package\PackageInterface;
/**
* Solver replace operation.
*
* @author Robert Schönthal <seroscho@googlemail.com>
*/
class ReplaceOperation extends SolverOperation
{
protected $package;
/**
* Initializes operation.
*
* @param PackageInterface $package package instance
* @param string $reason operation reason
*/
public function __construct(PackageInterface $package, $reason = null)
{
parent::__construct($reason);
$this->package = $package;
}
/**
* Returns package instance.
*
* @return PackageInterface
*/
public function getPackage()
{
return $this->package;
}
/**
* Returns job type.
*
* @return string
*/
public function getJobType()
{
return 'replace';
}
/**
* {@inheritDoc}
*/
public function __toString()
{
return 'Replacing '.$this->package->getPrettyName().' ('.$this->package->getPrettyVersion().')';
}
}

View File

@ -161,17 +161,6 @@ class InstallationManager
$installer->uninstall($operation->getPackage());
}
/**
* Replaces package.
*
* @param ReplaceOperation $operation operation instance
*/
public function replace(ReplaceOperation $operation)
{
$installer = $this->getInstaller($operation->getPackage()->getType());
$installer->replace($operation->getPackage());
}
/**
* Returns the installation path of a package
*

View File

@ -63,13 +63,6 @@ interface InstallerInterface
*/
function uninstall(PackageInterface $package);
/**
* Replaces specific package.
*
* @param PackageInterface $package package instance
*/
function replace(PackageInterface $package);
/**
* Returns the installation path of a package
*

View File

@ -80,11 +80,20 @@ class LibraryInstaller implements InstallerInterface
*/
public function install(PackageInterface $package)
{
$downloadPath = $this->getInstallPath($package);
$broken = !is_readable($this->getInstallPath($package));
//remove the binaries first if its missing on filesystem
if ($broken) {
$this->removeBinaries($package);
}
$downloadPath = $this->getInstallPath($package);
$this->downloadManager->download($package, $downloadPath);
$this->installBinaries($package);
$this->repository->addPackage(clone $package);
if($broken) {
$this->repository->addPackage(clone $package);
}
}
/**
@ -123,23 +132,6 @@ class LibraryInstaller implements InstallerInterface
$this->repository->removePackage($package);
}
/**
* {@inheritDoc}
*/
public function replace(PackageInterface $package)
{
if (!$this->repository->hasPackage($package)) {
throw new \InvalidArgumentException('Package is not installed: '.$package);
}
$downloadPath = $this->getInstallPath($package);
$this->removeBinaries($package);
$this->downloadManager->download($package, $downloadPath);
$this->installBinaries($package);
}
/**
* {@inheritDoc}
*/

View File

@ -14,6 +14,5 @@ class Custom implements InstallerInterface
public function install(PackageInterface $package) {}
public function update(PackageInterface $initial, PackageInterface $target) {}
public function uninstall(PackageInterface $package) {}
public function replace(PackageInterface $package) {}
public function getInstallPath(PackageInterface $package) {}
}

View File

@ -14,6 +14,5 @@ class Custom2 implements InstallerInterface
public function install(PackageInterface $package) {}
public function update(PackageInterface $initial, PackageInterface $target) {}
public function uninstall(PackageInterface $package) {}
public function replace(PackageInterface $package) {}
public function getInstallPath(PackageInterface $package) {}
}

View File

@ -14,6 +14,5 @@ class Custom2 implements InstallerInterface
public function install(PackageInterface $package) {}
public function update(PackageInterface $initial, PackageInterface $target) {}
public function uninstall(PackageInterface $package) {}
public function replace(PackageInterface $package) {}
public function getInstallPath(PackageInterface $package) {}
}

View File

@ -85,7 +85,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
$package = $this->createPackageMock();
$package
->expects($this->once())
->expects($this->exactly(2))
->method('getPrettyName')
->will($this->returnValue('some/package'));
@ -175,30 +175,6 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
$library->uninstall($package);
}
public function testReplace()
{
$library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
$package = $this->createPackageMock();
$package
->expects($this->once())
->method('getPrettyName')
->will($this->returnValue('pkg'));
$this->repository
->expects($this->once())
->method('hasPackage')
->with($package)
->will($this->onConsecutiveCalls(true, false));
$this->dm
->expects($this->once())
->method('download')
->with($package, $this->vendorDir.'/pkg');
$library->replace($package);
}
public function testGetInstallPath()
{
$library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);