Force dev packages to be installed from source

main
Jordi Boggiano 13 years ago
parent f73c08043f
commit 3fe87b1e35

@ -125,14 +125,14 @@ class DownloadManager
$sourceType = $package->getSourceType(); $sourceType = $package->getSourceType();
$distType = $package->getDistType(); $distType = $package->getDistType();
if (!($preferSource && $sourceType) && $distType) { if (!$package->isDev() && !($preferSource && $sourceType) && $distType) {
$package->setInstallationSource('dist'); $package->setInstallationSource('dist');
} elseif ($sourceType) { } elseif ($sourceType) {
$package->setInstallationSource('source'); $package->setInstallationSource('source');
} elseif ($package->isDev()) {
throw new \InvalidArgumentException('Dev package '.$package.' must have a source specified');
} else { } else {
throw new \InvalidArgumentException( throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
'Package '.$package.' should have source or dist specified'
);
} }
$fs = new Filesystem(); $fs = new Filesystem();

@ -109,7 +109,9 @@ class LibraryInstaller implements InstallerInterface
$this->downloadManager->update($initial, $target, $downloadPath); $this->downloadManager->update($initial, $target, $downloadPath);
$this->installBinaries($target); $this->installBinaries($target);
$this->repository->removePackage($initial); $this->repository->removePackage($initial);
$this->repository->addPackage(clone $target); if (!$this->repository->hasPackage($target)) {
$this->repository->addPackage(clone $target);
}
} }
/** /**

@ -41,6 +41,7 @@ class MemoryPackage extends BasePackage
protected $extra = array(); protected $extra = array();
protected $binaries = array(); protected $binaries = array();
protected $scripts = array(); protected $scripts = array();
protected $dev;
protected $requires = array(); protected $requires = array();
protected $conflicts = array(); protected $conflicts = array();
@ -63,6 +64,16 @@ class MemoryPackage extends BasePackage
$this->version = $version; $this->version = $version;
$this->prettyVersion = $prettyVersion; $this->prettyVersion = $prettyVersion;
$this->dev = 'dev-' === substr($version, 0, 4) || '-dev' === substr($version, -4);
}
/**
* {@inheritDoc}
*/
public function isDev()
{
return $this->dev;
} }
/** /**

@ -68,6 +68,13 @@ interface PackageInterface
*/ */
function matches($name, LinkConstraintInterface $constraint); function matches($name, LinkConstraintInterface $constraint);
/**
* Returns whether the package is a development virtual package or a concrete one
*
* @return Boolean
*/
function isDev();
/** /**
* Returns the package type, e.g. library * Returns the package type, e.g. library
* *

@ -67,9 +67,9 @@ class InstallerInstallerTest extends \PHPUnit_Framework_TestCase
->method('getPackages') ->method('getPackages')
->will($this->returnValue(array($this->packages[0]))); ->will($this->returnValue(array($this->packages[0])));
$this->repository $this->repository
->expects($this->once()) ->expects($this->exactly(2))
->method('hasPackage') ->method('hasPackage')
->will($this->returnValue(true)); ->will($this->onConsecutiveCalls(true, false));
$installer = new InstallerInstallerMock(__DIR__.'/Fixtures/', __DIR__.'/Fixtures/bin', $this->dm, $this->repository, $this->io, $this->im); $installer = new InstallerInstallerMock(__DIR__.'/Fixtures/', __DIR__.'/Fixtures/bin', $this->dm, $this->repository, $this->io, $this->im);
$test = $this; $test = $this;
@ -90,9 +90,9 @@ class InstallerInstallerTest extends \PHPUnit_Framework_TestCase
->method('getPackages') ->method('getPackages')
->will($this->returnValue(array($this->packages[1]))); ->will($this->returnValue(array($this->packages[1])));
$this->repository $this->repository
->expects($this->once()) ->expects($this->exactly(2))
->method('hasPackage') ->method('hasPackage')
->will($this->returnValue(true)); ->will($this->onConsecutiveCalls(true, false));
$installer = new InstallerInstallerMock(__DIR__.'/Fixtures/', __DIR__.'/Fixtures/bin', $this->dm, $this->repository, $this->io, $this->im); $installer = new InstallerInstallerMock(__DIR__.'/Fixtures/', __DIR__.'/Fixtures/bin', $this->dm, $this->repository, $this->io, $this->im);
$test = $this; $test = $this;

@ -128,10 +128,9 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('package1')); ->will($this->returnValue('package1'));
$this->repository $this->repository
->expects($this->exactly(2)) ->expects($this->exactly(3))
->method('hasPackage') ->method('hasPackage')
->with($initial) ->will($this->onConsecutiveCalls(true, false, false));
->will($this->onConsecutiveCalls(true, false));
$this->dm $this->dm
->expects($this->once()) ->expects($this->once())

Loading…
Cancel
Save