Adjust tests and fix installer code to create the pool using locked requirements and not the composer.json reqs
parent
df23836a0e
commit
b4698568d2
|
@ -33,6 +33,7 @@ use Composer\Json\JsonFile;
|
||||||
use Composer\Package\AliasPackage;
|
use Composer\Package\AliasPackage;
|
||||||
use Composer\Package\CompletePackage;
|
use Composer\Package\CompletePackage;
|
||||||
use Composer\Package\Link;
|
use Composer\Package\Link;
|
||||||
|
use Composer\Package\LinkConstraint\EmptyConstraint;
|
||||||
use Composer\Package\LinkConstraint\VersionConstraint;
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||||
use Composer\Package\Locker;
|
use Composer\Package\Locker;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
|
@ -355,9 +356,6 @@ class Installer
|
||||||
$installFromLock = false;
|
$installFromLock = false;
|
||||||
if (!$this->update && $this->locker->isLocked()) {
|
if (!$this->update && $this->locker->isLocked()) {
|
||||||
$installFromLock = true;
|
$installFromLock = true;
|
||||||
// we are removing all requirements from the root package so only the lock file is relevant for installation rules
|
|
||||||
$this->package->setRequires(array());
|
|
||||||
$this->package->setDevRequires(array());
|
|
||||||
try {
|
try {
|
||||||
$lockedRepository = $this->locker->getLockedRepository($withDevReqs);
|
$lockedRepository = $this->locker->getLockedRepository($withDevReqs);
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
|
@ -381,7 +379,7 @@ class Installer
|
||||||
|
|
||||||
// creating repository pool
|
// creating repository pool
|
||||||
$policy = $this->createPolicy();
|
$policy = $this->createPolicy();
|
||||||
$pool = $this->createPool($withDevReqs);
|
$pool = $this->createPool($withDevReqs, $lockedRepository);
|
||||||
$pool->addRepository($installedRepo, $aliases);
|
$pool->addRepository($installedRepo, $aliases);
|
||||||
if ($installFromLock) {
|
if ($installFromLock) {
|
||||||
$pool->addRepository($lockedRepository, $aliases);
|
$pool->addRepository($lockedRepository, $aliases);
|
||||||
|
@ -674,27 +672,39 @@ class Installer
|
||||||
return array_merge($uninstOps, $operations);
|
return array_merge($uninstOps, $operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createPool($withDevReqs)
|
private function createPool($withDevReqs, RepositoryInterface $lockedRepository = null)
|
||||||
{
|
{
|
||||||
$minimumStability = $this->package->getMinimumStability();
|
if (!$this->update && $this->locker->isLocked()) { // install from lock
|
||||||
$stabilityFlags = $this->package->getStabilityFlags();
|
|
||||||
|
|
||||||
if (!$this->update && $this->locker->isLocked()) {
|
|
||||||
$minimumStability = $this->locker->getMinimumStability();
|
$minimumStability = $this->locker->getMinimumStability();
|
||||||
$stabilityFlags = $this->locker->getStabilityFlags();
|
$stabilityFlags = $this->locker->getStabilityFlags();
|
||||||
|
|
||||||
|
$requires = array();
|
||||||
|
foreach ($lockedRepository->getPackages() as $package) {
|
||||||
|
$constraint = new VersionConstraint('=', $package->getVersion());
|
||||||
|
$constraint->setPrettyString($package->getPrettyVersion());
|
||||||
|
$requires[$package->getName()] = $constraint;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$minimumStability = $this->package->getMinimumStability();
|
||||||
|
$stabilityFlags = $this->package->getStabilityFlags();
|
||||||
|
|
||||||
$requires = $this->package->getRequires();
|
$requires = $this->package->getRequires();
|
||||||
if ($withDevReqs) {
|
if ($withDevReqs) {
|
||||||
$requires = array_merge($requires, $this->package->getDevRequires());
|
$requires = array_merge($requires, $this->package->getDevRequires());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rootConstraints = array();
|
$rootConstraints = array();
|
||||||
foreach ($requires as $req => $constraint) {
|
foreach ($requires as $req => $constraint) {
|
||||||
// skip platform requirements from the root package to avoid filtering out existing platform packages
|
// skip platform requirements from the root package to avoid filtering out existing platform packages
|
||||||
if ($this->ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
|
if ($this->ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ($constraint instanceof Link) {
|
||||||
$rootConstraints[$req] = $constraint->getConstraint();
|
$rootConstraints[$req] = $constraint->getConstraint();
|
||||||
|
} else {
|
||||||
|
$rootConstraints[$req] = $constraint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pool($minimumStability, $stabilityFlags, $rootConstraints);
|
return new Pool($minimumStability, $stabilityFlags, $rootConstraints);
|
||||||
|
|
|
@ -20,8 +20,8 @@ Requiring a replaced package in a version, that is not provided by the replacing
|
||||||
--LOCK--
|
--LOCK--
|
||||||
{
|
{
|
||||||
"packages": [
|
"packages": [
|
||||||
{ "name": "foo/original", "version": "1.0.0", "replace": {"foo/replaced": "1.0.0"} },
|
{ "name": "foo/original", "version": "1.0.0", "replace": {"foo/replaced": "1.0.0"}, "type": "library" },
|
||||||
{ "name": "foo/replaced", "version": "2.0.0" }
|
{ "name": "foo/replaced", "version": "2.0.0", "type": "library" }
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
@ -35,5 +35,7 @@ Requiring a replaced package in a version, that is not provided by the replacing
|
||||||
--RUN--
|
--RUN--
|
||||||
install
|
install
|
||||||
--EXPECT-EXIT-CODE--
|
--EXPECT-EXIT-CODE--
|
||||||
2
|
0
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
Installing foo/original (1.0.0)
|
||||||
|
Installing foo/replaced (2.0.0)
|
||||||
|
|
|
@ -19,6 +19,23 @@ Requiring a replaced package in a version, that is not provided by the replacing
|
||||||
}
|
}
|
||||||
--RUN--
|
--RUN--
|
||||||
install
|
install
|
||||||
|
--EXPECT-LOCK--
|
||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
{ "name": "foo/original", "version": "1.0.0", "replace": {"foo/replaced": "1.0.0"}, "type": "library" },
|
||||||
|
{ "name": "foo/replaced", "version": "2.0.0", "type": "library" }
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": {},
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": []
|
||||||
|
}
|
||||||
--EXPECT-EXIT-CODE--
|
--EXPECT-EXIT-CODE--
|
||||||
2
|
0
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
Installing foo/original (1.0.0)
|
||||||
|
Installing foo/replaced (2.0.0)
|
||||||
|
|
Loading…
Reference in New Issue