From 68512714f4db1313eb2fe54a28fded8915a6a741 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 21 Nov 2011 18:18:06 +0100 Subject: [PATCH] Fix update command by using remove+install (and for now ignoring uninstalls of non-existing packages) --- src/Composer/Command/InstallCommand.php | 15 +++++++-------- src/Composer/Installer/LibraryInstaller.php | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 33dd826db..95c95371f 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -91,19 +91,18 @@ EOT foreach ($installedPackages as $package) { if ($package->getName() === $link->getTarget()) { - $request->update($link->getTarget(), $link->getConstraint()); - continue 2; + $constraint = new VersionConstraint('=', $package->getVersion()); + if ($link->getConstraint()->matches($constraint)) { + continue 2; + } + // TODO this should just update to the exact version (once constraints are available on update, see #125) + $request->remove($package->getName(), $constraint); + break; } } $request->install($link->getTarget(), $link->getConstraint()); } - - foreach ($localRepo->getPackages() as $package) { - if (!in_array($package->getName(), $listedPackages)) { - $request->remove($package->getName()); - } - } } elseif ($composer->getLocker()->isLocked()) { $output->writeln('> Found lockfile. Reading.'); diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 898c4a6b9..d67d514ae 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -109,6 +109,8 @@ class LibraryInstaller implements InstallerInterface public function uninstall(PackageInterface $package) { if (!$this->repository->hasPackage($package)) { + // TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125) + return; throw new \InvalidArgumentException('Package is not installed: '.$package); }