Explorar o código

Merge branch '1.3'

Jordi Boggiano %!s(int64=8) %!d(string=hai) anos
pai
achega
0ecd1f5eb5

+ 6 - 0
doc/articles/custom-installers.md

@@ -85,10 +85,16 @@ Example:
     },
     "require": {
         "composer-plugin-api": "^1.0"
+    },
+    "require-dev": {
+        "composer/composer": "^1.3"
     }
 }
 ```
 
+The example above has Composer itself in its require-dev, which allows you to use
+the Composer classes in your test suite for example.
+
 ### The Plugin class
 
 The class defining the Composer plugin must implement the

+ 6 - 6
src/Composer/EventDispatcher/EventDispatcher.php

@@ -177,13 +177,13 @@ class EventDispatcher
                 if (substr($callable, 0, 10) === '@composer ') {
                     $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9);
                     if (0 !== ($exitCode = $this->process->execute($exec))) {
-                        $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()));
+                        $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
 
                         throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
                     }
                 } else {
                     if (!$this->getListeners(new Event($scriptName))) {
-                        $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable));
+                        $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
                     }
 
                     $return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags));
@@ -193,11 +193,11 @@ class EventDispatcher
                 $methodName = substr($callable, strpos($callable, '::') + 2);
 
                 if (!class_exists($className)) {
-                    $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>');
+                    $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
                     continue;
                 }
                 if (!is_callable($callable)) {
-                    $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>');
+                    $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
                     continue;
                 }
 
@@ -205,7 +205,7 @@ class EventDispatcher
                     $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
                 } catch (\Exception $e) {
                     $message = "Script %s handling the %s event terminated with an exception";
-                    $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>');
+                    $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
                     throw $e;
                 }
             } else {
@@ -233,7 +233,7 @@ class EventDispatcher
                 }
 
                 if (0 !== ($exitCode = $this->process->execute($exec))) {
-                    $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()));
+                    $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
 
                     throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
                 }

+ 3 - 3
src/Composer/Package/Version/VersionGuesser.php

@@ -65,17 +65,17 @@ class VersionGuesser
     {
         if (function_exists('proc_open')) {
             $versionData = $this->guessGitVersion($packageConfig, $path);
-            if (null !== $versionData) {
+            if (null !== $versionData && null !== $versionData['version']) {
                 return $versionData;
             }
 
             $versionData = $this->guessHgVersion($packageConfig, $path);
-            if (null !== $versionData) {
+            if (null !== $versionData && null !== $versionData['version']) {
                 return $versionData;
             }
 
             $versionData = $this->guessFossilVersion($packageConfig, $path);
-            if (null !== $versionData) {
+            if (null !== $versionData && null !== $versionData['version']) {
                 return $versionData;
             }
 

+ 2 - 2
src/Composer/Script/ScriptEvents.php

@@ -95,7 +95,7 @@ class ScriptEvents
     /**
      * The POST_ROOT_PACKAGE_INSTALL event occurs after the root package has been installed.
      *
-     * The event listener method receives a Composer\Installer\PackageEvent instance.
+     * The event listener method receives a Composer\Script\Event instance.
      *
      * @var string
      */
@@ -105,7 +105,7 @@ class ScriptEvents
      * The POST_CREATE_PROJECT event occurs after the create-project command has been executed.
      * Note: Event occurs after POST_INSTALL_CMD
      *
-     * The event listener method receives a Composer\Installer\PackageEvent instance.
+     * The event listener method receives a Composer\Script\Event instance.
      *
      * @var string
      */

+ 3 - 2
src/Composer/Util/RemoteFilesystem.php

@@ -348,7 +348,7 @@ class RemoteFilesystem
         if ($originUrl === 'bitbucket.org'
             && !$this->isPublicBitBucketDownload($fileUrl)
             && substr($fileUrl, -4) === '.zip'
-            && preg_match('{^text/html\b}i', $contentType)
+            && $contentType && preg_match('{^text/html\b}i', $contentType)
         ) {
             $result = false;
             if ($this->retryAuthFailure) {
@@ -385,7 +385,8 @@ class RemoteFilesystem
 
         // decode gzip
         if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http' && !$hasFollowedRedirect) {
-            $decode = 'gzip' === strtolower($this->findHeaderValue($http_response_header, 'content-encoding'));
+            $contentEncoding = $this->findHeaderValue($http_response_header, 'content-encoding');
+            $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
 
             if ($decode) {
                 try {