Browse Source

Fixed getLocalChanges calls in VCS downloaders to match new function interface

Sascha Egerer 11 years ago
parent
commit
80cebbd4be

+ 4 - 4
src/Composer/Downloader/GitDownloader.php

@@ -97,11 +97,11 @@ class GitDownloader extends VcsDownloader
     /**
      * {@inheritDoc}
      */
-    protected function cleanChanges($path, $update)
+    protected function cleanChanges($path, $update, $package)
     {
         $this->cleanEnv();
         $path = $this->normalizePath($path);
-        if (!$changes = $this->getLocalChanges($path)) {
+        if (!$changes = $this->getLocalChanges($path, $package)) {
             return;
         }
 
@@ -112,13 +112,13 @@ class GitDownloader extends VcsDownloader
             }
             if ('stash' === $discardChanges) {
                 if (!$update) {
-                    return parent::cleanChanges($path, $update);
+                    return parent::cleanChanges($path, $update, $package);
                 }
 
                 return $this->stashChanges($path);
             }
 
-            return parent::cleanChanges($path, $update);
+            return parent::cleanChanges($path, $update, $package);
         }
 
         $changes = array_map(function ($elem) {

+ 3 - 3
src/Composer/Downloader/SvnDownloader.php

@@ -90,9 +90,9 @@ class SvnDownloader extends VcsDownloader
     /**
      * {@inheritDoc}
      */
-    protected function cleanChanges($path, $update)
+    protected function cleanChanges($path, $update, $package)
     {
-        if (!$changes = $this->getLocalChanges($path)) {
+        if (!$changes = $this->getLocalChanges($path, $package)) {
             return;
         }
 
@@ -101,7 +101,7 @@ class SvnDownloader extends VcsDownloader
                 return $this->discardChanges($path);
             }
 
-            return parent::cleanChanges($path, $update);
+            return parent::cleanChanges($path, $update, $package);
         }
 
         $changes = array_map(function ($elem) {

+ 13 - 12
src/Composer/Downloader/VcsDownloader.php

@@ -86,7 +86,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
 
         $this->io->write("  - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
 
-        $this->cleanChanges($path, true);
+        $this->cleanChanges($path, true, $initial);
         try {
             $this->doUpdate($initial, $target, $path);
         } catch (\Exception $e) {
@@ -126,7 +126,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
     public function remove(PackageInterface $package, $path)
     {
         $this->io->write("  - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
-        $this->cleanChanges($path, false);
+        $this->cleanChanges($path, false, $package);
         if (!$this->filesystem->removeDirectory($path)) {
             // retry after a bit on windows since it tends to be touchy with mass removals
             if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(250) && !$this->filesystem->removeDirectory($path))) {
@@ -144,18 +144,19 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
         return $this;
     }
 
-    /**
-     * Prompt the user to check if changes should be stashed/removed or the operation aborted
-     *
-     * @param string $path
-     * @param bool   $update if true (update) the changes can be stashed and reapplied after an update,
-     *                                  if false (remove) the changes should be assumed to be lost if the operation is not aborted
-     * @throws \RuntimeException in case the operation must be aborted
-     */
-    protected function cleanChanges($path, $update)
+	/**
+	 * Prompt the user to check if changes should be stashed/removed or the operation aborted
+	 *
+	 * @param string $path
+	 * @param bool $update if true (update) the changes can be stashed and reapplied after an update,
+	 *                                  if false (remove) the changes should be assumed to be lost if the operation is not aborted
+	 * @param PackageInterface $package
+	 * @throws \RuntimeException in case the operation must be aborted
+	 */
+    protected function cleanChanges($path, $update, $package)
     {
         // the default implementation just fails if there are any changes, override in child classes to provide stash-ability
-        if (null !== $this->getLocalChanges($path)) {
+        if (null !== $this->getLocalChanges($path, $package)) {
             throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
         }
     }