Fix calculation of lock transaction updates and start updating output in tests
parent
f1e4ccbe1d
commit
06d11f2f38
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace Composer\DependencyResolver;
|
||||
|
||||
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
||||
use Composer\DependencyResolver\Operation\UninstallOperation;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
|
@ -86,7 +88,6 @@ class LocalRepoTransaction
|
|||
$operations = $this->movePluginsToFront($operations);
|
||||
$operations = $this->moveUninstallsToFront($operations);
|
||||
|
||||
|
||||
// TODO skip updates which don't update? is this needed? we shouldn't schedule this update in the first place?
|
||||
/*
|
||||
if ('update' === $jobType) {
|
||||
|
@ -175,7 +176,7 @@ class LocalRepoTransaction
|
|||
{
|
||||
$uninstOps = array();
|
||||
foreach ($operations as $idx => $op) {
|
||||
if ($op instanceof UninstallOperation) {
|
||||
if ($op instanceof UninstallOperation || $op instanceof MarkAliasUninstalledOperation) {
|
||||
$uninstOps[] = $op;
|
||||
unset($operations[$idx]);
|
||||
}
|
||||
|
|
|
@ -78,8 +78,8 @@ class LockTransaction
|
|||
$operations[] = new Operation\UpdateOperation($lockMeansUpdateMap[abs($literal)], $package, $reason);
|
||||
|
||||
// avoid updates to one package from multiple origins
|
||||
$ignoreRemove[$lockMeansUpdateMap[abs($literal)]->id] = true;
|
||||
unset($lockMeansUpdateMap[abs($literal)]);
|
||||
$ignoreRemove[$source->id] = true;
|
||||
} else {
|
||||
if ($package instanceof AliasPackage) {
|
||||
$operations[] = new Operation\MarkAliasInstalledOperation($package, $reason);
|
||||
|
|
|
@ -90,7 +90,7 @@ class Request
|
|||
$presentMap = array();
|
||||
|
||||
if ($this->lockedRepository) {
|
||||
foreach ($this->lockedRepository as $package) {
|
||||
foreach ($this->lockedRepository->getPackages() as $package) {
|
||||
$presentMap[$package->id] = $package;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ class Installer
|
|||
}
|
||||
// TODO can we drop any locked packages that we have matching remote versions for?
|
||||
|
||||
$request = $this->createRequest($this->fixedRootPackage, $platformRepo);
|
||||
$request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
|
||||
|
||||
if ($lockedRepository) {
|
||||
// TODO do we really always need this? Maybe only to skip fix() in updateWhitelist case cause these packages get removed on full update automatically?
|
||||
|
@ -422,23 +422,6 @@ class Installer
|
|||
$platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
|
||||
$platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
|
||||
|
||||
$updatedLock = $this->locker->setLockData(
|
||||
$lockTransaction->getNewLockNonDevPackages(),
|
||||
$lockTransaction->getNewLockDevPackages(),
|
||||
$platformReqs,
|
||||
$platformDevReqs,
|
||||
$aliases,
|
||||
$this->package->getMinimumStability(),
|
||||
$this->package->getStabilityFlags(),
|
||||
$this->preferStable || $this->package->getPreferStable(),
|
||||
$this->preferLowest,
|
||||
$this->config->get('platform') ?: array(),
|
||||
$this->writeLock && $this->executeOperations
|
||||
);
|
||||
if ($updatedLock && $this->writeLock && $this->executeOperations) {
|
||||
$this->io->writeError('<info>Writing lock file</info>');
|
||||
}
|
||||
|
||||
if ($lockTransaction->getOperations()) {
|
||||
$installs = $updates = $uninstalls = array();
|
||||
foreach ($lockTransaction->getOperations() as $operation) {
|
||||
|
@ -501,7 +484,22 @@ class Installer
|
|||
}
|
||||
}
|
||||
|
||||
$this->io->write('foo');
|
||||
$updatedLock = $this->locker->setLockData(
|
||||
$lockTransaction->getNewLockNonDevPackages(),
|
||||
$lockTransaction->getNewLockDevPackages(),
|
||||
$platformReqs,
|
||||
$platformDevReqs,
|
||||
$aliases,
|
||||
$this->package->getMinimumStability(),
|
||||
$this->package->getStabilityFlags(),
|
||||
$this->preferStable || $this->package->getPreferStable(),
|
||||
$this->preferLowest,
|
||||
$this->config->get('platform') ?: array(),
|
||||
$this->writeLock && $this->executeOperations
|
||||
);
|
||||
if ($updatedLock && $this->writeLock && $this->executeOperations) {
|
||||
$this->io->writeError('<info>Writing lock file</info>');
|
||||
}
|
||||
|
||||
if ($doInstall) {
|
||||
// TODO ensure lock is used from locker as-is, since it may not have been written to disk in case of executeOperations == false
|
||||
|
@ -530,7 +528,7 @@ class Installer
|
|||
$repositorySet = $this->createRepositorySet($platformRepo, $aliases, $lockedRepository);
|
||||
$repositorySet->addRepository($lockedRepository);
|
||||
|
||||
$this->io->writeError('<info>Installing dependencies'.($this->devMode ? ' (including require-dev)' : '').' from lock file</info>');
|
||||
$this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
|
||||
|
||||
// verify that the lock file works with the current platform repository
|
||||
// we can skip this part if we're doing this as the second step after an update
|
||||
|
@ -538,7 +536,7 @@ class Installer
|
|||
$this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
|
||||
|
||||
// creating requirements request
|
||||
$request = $this->createRequest($this->fixedRootPackage, $platformRepo);
|
||||
$request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
|
||||
|
||||
if (!$this->locker->isFresh()) {
|
||||
$this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>', true, IOInterface::QUIET);
|
||||
|
@ -627,7 +625,7 @@ class Installer
|
|||
}
|
||||
|
||||
// output op, but alias op only in debug verbosity
|
||||
if (false === strpos($operation->getJobType(), 'Alias') || $this->io->isDebug()) {
|
||||
if ((!$this->executeOperations && false === strpos($operation->getJobType(), 'Alias')) || $this->io->isDebug()) {
|
||||
$this->io->writeError(' - ' . $operation);
|
||||
}
|
||||
|
||||
|
@ -736,13 +734,14 @@ class Installer
|
|||
}
|
||||
|
||||
/**
|
||||
* @param RootPackageInterface $rootPackage
|
||||
* @param PlatformRepository $platformRepo
|
||||
* @param RootPackageInterface $rootPackage
|
||||
* @param PlatformRepository $platformRepo
|
||||
* @param RepositoryInterface|null $lockedRepository
|
||||
* @return Request
|
||||
*/
|
||||
private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo)
|
||||
private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, $lockedRepository = null)
|
||||
{
|
||||
$request = new Request();
|
||||
$request = new Request($lockedRepository);
|
||||
|
||||
$request->fixPackage($rootPackage, false);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ Broken dependencies should not lead to a replacer being installed which is not m
|
|||
install
|
||||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies (including require-dev)
|
||||
Updating dependencies
|
||||
Your requirements could not be resolved to an installable set of packages.
|
||||
|
||||
Problem 1
|
||||
|
|
|
@ -32,7 +32,7 @@ install
|
|||
|
||||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies (including require-dev)
|
||||
Updating dependencies
|
||||
Your requirements could not be resolved to an installable set of packages.
|
||||
|
||||
Problem 1
|
||||
|
|
|
@ -29,15 +29,37 @@ that are also a root package, when that root package is also explicitly whitelis
|
|||
{ "name": "a/a", "version": "1.0.0" },
|
||||
{ "name": "b/b", "version": "1.0.0", "require": { "a/a": "~1.0" } }
|
||||
]
|
||||
|
||||
--LOCK--
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "a/a", "version": "1.0.0"
|
||||
},
|
||||
{
|
||||
"name": "b/b", "version": "1.0.0", "require": { "a/a": "~1.0" }
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
--RUN--
|
||||
update a/a b/b --with-dependencies
|
||||
|
||||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies (including require-dev)
|
||||
Package operations: 0 installs, 2 updates, 0 removals
|
||||
Updating dependencies
|
||||
Lock file operations: 0 installs, 2 updates, 0 removals
|
||||
- Updating b/b (1.0.0) to b/b (1.1.0)
|
||||
- Updating a/a (1.0.0) to a/a (1.1.0)
|
||||
Writing lock file
|
||||
Installing dependencies from lock file (including require-dev)
|
||||
Package operations: 0 installs, 2 updates, 0 removals
|
||||
Generating autoload files
|
||||
|
||||
--EXPECT--
|
||||
|
|
|
@ -19,8 +19,11 @@ install --no-dev
|
|||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies
|
||||
Package operations: 1 install, 0 updates, 0 removals
|
||||
Lock file operations: 1 install, 0 updates, 0 removals
|
||||
- Installing a/a (1.0.0)
|
||||
Writing lock file
|
||||
Installing dependencies from lock file
|
||||
Package operations: 1 install, 0 updates, 0 removals
|
||||
Generating autoload files
|
||||
|
||||
--EXPECT--
|
||||
|
|
|
@ -18,10 +18,13 @@ Suggestions are displayed
|
|||
install
|
||||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies (including require-dev)
|
||||
Updating dependencies
|
||||
Lock file operations: 1 install, 0 updates, 0 removals
|
||||
- Installing a/a (1.0.0)
|
||||
Writing lock file
|
||||
Installing dependencies from lock file (including require-dev)
|
||||
Package operations: 1 install, 0 updates, 0 removals
|
||||
a/a suggests installing b/b (an obscure reason)
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
|
||||
--EXPECT--
|
||||
|
|
|
@ -16,7 +16,7 @@ Installing locked dev packages should remove old dependencies
|
|||
"require": {}
|
||||
}
|
||||
],
|
||||
"packages-dev": null,
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
|
|
Loading…
Reference in New Issue