Sfoglia il codice sorgente

Display Locking instead of Installing for lock file install operations

Nils Adermann 5 anni fa
parent
commit
3cbe91983c

+ 9 - 1
src/Composer/DependencyResolver/Operation/InstallOperation.php

@@ -56,11 +56,19 @@ class InstallOperation extends SolverOperation
         return 'install';
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public function show($lock)
+    {
+        return ($lock ? 'Locking ' : 'Installing ').$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
+    }
+
     /**
      * {@inheritDoc}
      */
     public function __toString()
     {
-        return 'Installing '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
+        return $this->show(false);
     }
 }

+ 9 - 1
src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php

@@ -60,8 +60,16 @@ class MarkAliasInstalledOperation extends SolverOperation
     /**
      * {@inheritDoc}
      */
-    public function __toString()
+    public function show($lock)
     {
         return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function __toString()
+    {
+        return $this->show(false);
+    }
 }

+ 9 - 1
src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php

@@ -60,8 +60,16 @@ class MarkAliasUninstalledOperation extends SolverOperation
     /**
      * {@inheritDoc}
      */
-    public function __toString()
+    public function show($lock)
     {
         return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function __toString()
+    {
+        return $this->show(false);
+    }
 }

+ 8 - 0
src/Composer/DependencyResolver/Operation/OperationInterface.php

@@ -33,6 +33,14 @@ interface OperationInterface
      */
     public function getReason();
 
+    /**
+     * Serializes the operation in a human readable format
+     *
+     * @param $lock bool Whether this is an operation on the lock file
+     * @return string
+     */
+    public function show($lock);
+
     /**
      * Serializes the operation in a human readable format
      *

+ 6 - 0
src/Composer/DependencyResolver/Operation/SolverOperation.php

@@ -43,6 +43,12 @@ abstract class SolverOperation implements OperationInterface
         return $this->reason;
     }
 
+    /**
+     * @param $lock bool Whether this is an operation on the lock file
+    * @return string
+    */
+    abstract public function show($lock);
+
     protected function formatVersion(PackageInterface $package)
     {
         return $package->getFullPrettyVersion();

+ 9 - 1
src/Composer/DependencyResolver/Operation/UninstallOperation.php

@@ -59,8 +59,16 @@ class UninstallOperation extends SolverOperation
     /**
      * {@inheritDoc}
      */
-    public function __toString()
+    public function show($lock)
     {
         return 'Uninstalling '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function __toString()
+    {
+        return $this->show(false);
+    }
 }

+ 9 - 1
src/Composer/DependencyResolver/Operation/UpdateOperation.php

@@ -72,9 +72,17 @@ class UpdateOperation extends SolverOperation
     /**
      * {@inheritDoc}
      */
-    public function __toString()
+    public function show($lock)
     {
         return 'Updating '.$this->initialPackage->getPrettyName().' ('.$this->formatVersion($this->initialPackage).') to '.
             $this->targetPackage->getPrettyName(). ' ('.$this->formatVersion($this->targetPackage).')';
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function __toString()
+    {
+        return $this->show(false);
+    }
 }

+ 1 - 2
src/Composer/DependencyResolver/Transaction.php

@@ -24,7 +24,7 @@ use Composer\Semver\Constraint\Constraint;
 /**
  * @author Nils Adermann <naderman@naderman.de>
  */
-abstract class Transaction
+class Transaction
 {
     /**
      * @var array
@@ -53,7 +53,6 @@ abstract class Transaction
         $this->presentPackages = $presentPackages;
         $this->setResultPackageMaps($resultPackages);
         $this->operations = $this->calculateOperations();
-
     }
 
     public function getOperations()

+ 2 - 2
src/Composer/Installer.php

@@ -484,7 +484,7 @@ class Installer
 
             // output op, but alias op only in debug verbosity
             if (false === strpos($operation->getJobType(), 'Alias') || $this->io->isDebug()) {
-                $this->io->writeError('  - ' . $operation);
+                $this->io->writeError('  - ' . $operation->show(true));
             }
         }
 
@@ -673,7 +673,7 @@ class Installer
 
             // output op, but alias op only in debug verbosity
             if ((!$this->executeOperations && false === strpos($operation->getJobType(), 'Alias')) || $this->io->isDebug()) {
-                $this->io->writeError('  - ' . $operation);
+                $this->io->writeError('  - ' . $operation->show(false));
             }
 
             $this->installationManager->execute($localRepo, $operation);

+ 2 - 2
tests/Composer/Test/Fixtures/installer/abandoned-listed.test

@@ -27,8 +27,8 @@ update
 Loading composer repositories with package information
 Updating dependencies
 Lock file operations: 2 installs, 0 updates, 0 removals
-  - Installing a/a (1.0.0)
-  - Installing c/c (1.0.0)
+  - Locking a/a (1.0.0)
+  - Locking c/c (1.0.0)
 Writing lock file
 Installing dependencies from lock file (including require-dev)
 Package operations: 2 installs, 0 updates, 0 removals

+ 2 - 2
tests/Composer/Test/Fixtures/installer/suggest-installed.test

@@ -22,8 +22,8 @@ update
 Loading composer repositories with package information
 Updating dependencies
 Lock file operations: 2 installs, 0 updates, 0 removals
-  - Installing a/a (1.0.0)
-  - Installing b/b (1.0.0)
+  - Locking a/a (1.0.0)
+  - Locking b/b (1.0.0)
 Writing lock file
 Installing dependencies from lock file (including require-dev)
 Package operations: 2 installs, 0 updates, 0 removals

+ 1 - 1
tests/Composer/Test/Fixtures/installer/suggest-prod.test

@@ -21,7 +21,7 @@ install --no-dev
 Loading composer repositories with package information
 Updating dependencies
 Lock file operations: 1 install, 0 updates, 0 removals
-  - Installing a/a (1.0.0)
+  - Locking a/a (1.0.0)
 Writing lock file
 Installing dependencies from lock file
 Package operations: 1 install, 0 updates, 0 removals

+ 2 - 2
tests/Composer/Test/Fixtures/installer/suggest-replaced.test

@@ -22,8 +22,8 @@ update
 Loading composer repositories with package information
 Updating dependencies
 Lock file operations: 2 installs, 0 updates, 0 removals
-  - Installing c/c (1.0.0)
-  - Installing a/a (1.0.0)
+  - Locking c/c (1.0.0)
+  - Locking a/a (1.0.0)
 Writing lock file
 Installing dependencies from lock file (including require-dev)
 Package operations: 2 installs, 0 updates, 0 removals

+ 1 - 1
tests/Composer/Test/Fixtures/installer/suggest-uninstalled.test

@@ -21,7 +21,7 @@ install
 Loading composer repositories with package information
 Updating dependencies
 Lock file operations: 1 install, 0 updates, 0 removals
-  - Installing a/a (1.0.0)
+  - Locking a/a (1.0.0)
 Writing lock file
 Installing dependencies from lock file (including require-dev)
 Package operations: 1 install, 0 updates, 0 removals