diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 6763d24d6..3ae00c228 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -48,7 +48,6 @@ class InstallCommand extends Command new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'), new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'), - new InputOption('ignore-missing-metadata', null, InputOption::VALUE_NONE, 'Ignore missing .git|.svn|.hg metadata repositories (when updating or reinstalling).'), new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'), )) ->setHelp(<<getComposer(true, $input->getOption('no-plugins')); $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress')); - $composer->getDownloadManager()->setForceUpdate($input->getOption('ignore-missing-metadata')); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output); $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent); diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 684b64111..902e8beaf 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -26,7 +26,6 @@ class DownloadManager private $io; private $preferDist = false; private $preferSource = false; - private $forceUpdate = false; private $filesystem; private $downloaders = array(); @@ -70,20 +69,6 @@ class DownloadManager return $this; } - /** - * set force update mode - * forces to update the repository event when missing metadata - * - * @param $forceUpdate - * @return DownloadManager - */ - public function setForceUpdate($forceUpdate) - { - $this->forceUpdate = (boolean) $forceUpdate; - - return $this; - } - /** * Sets whether to output download progress information for all registered * downloaders @@ -268,8 +253,9 @@ class DownloadManager try { $downloader->update($initial, $target, $targetDir); return; - } catch (VcsMissingMetadataException $ex) { - if ($this->forceUpdate === false) { + } catch (\RuntimeException $ex) { + if (!$this->io->isInteractive() || + !$this->io->askConfirmation(' Updating failed. Would you like to try reinstalling instead [yes]? ', true)) { throw $ex; } } diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index d3eb6509c..84d1f735f 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -73,7 +73,7 @@ class GitDownloader extends VcsDownloader { GitUtil::cleanEnv(); if (!$this->hasMetadataRepository($path)) { - throw new VcsMissingMetadataException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); + throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); } $ref = $target->getSourceReference(); diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php index 06fc4fbe9..9c379a9e5 100644 --- a/src/Composer/Downloader/HgDownloader.php +++ b/src/Composer/Downloader/HgDownloader.php @@ -48,7 +48,7 @@ class HgDownloader extends VcsDownloader $this->io->writeError(" Updating to ".$target->getSourceReference()); if (!$this->hasMetadataRepository($path)) { - throw new VcsMissingMetadataException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); + throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); } $command = sprintf('hg pull %s && hg up %s', $url, $ref); diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php index a8a856a33..42ebf758e 100644 --- a/src/Composer/Downloader/SvnDownloader.php +++ b/src/Composer/Downloader/SvnDownloader.php @@ -53,7 +53,7 @@ class SvnDownloader extends VcsDownloader $ref = $target->getSourceReference(); if (!$this->hasMetadataRepository($path)) { - throw new VcsMissingMetadataException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); + throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); } $flags = ""; diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index be6391046..37aa9042f 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -131,15 +131,9 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa $this->reapplyChanges($path); - if (!$this->hasMetadataRepository($path) && !$urls && $exception) { - if (!$this->io->isDebug()) { - $this->io->write(' The VCS directory is missing from vendor package, see https://getcomposer.org/commit-deps for more information'); - } - throw $exception; - } - - // print the commit logs if in verbose mode - if ($this->io->isVerbose()) { + // print the commit logs if in verbose mode and VCS metadata is present + // because in case of missing metadata code would trigger another exception + if ($this->io->isVerbose() && $this->hasMetadataRepository($path)) { $message = 'Pulling in changes:'; $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path); @@ -161,6 +155,10 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa } } + if (!$urls && $exception) { + throw $exception; + } + $this->io->writeError(''); } diff --git a/src/Composer/Downloader/VcsMissingMetadataException.php b/src/Composer/Downloader/VcsMissingMetadataException.php deleted file mode 100644 index f450edcf5..000000000 --- a/src/Composer/Downloader/VcsMissingMetadataException.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ -class VcsMissingMetadataException extends \RuntimeException -{ - /** - * Construct the exception. Note: The message is NOT binary safe. - * @link http://php.net/manual/en/exception.construct.php - * @param string $message [optional] The Exception message to throw. - * @param int $code [optional] The Exception code. - * @param \Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 - * @since 5.1.0 - */ - public function __construct($message = '', $code = 0, \Exception $previous = null) - { - parent::__construct("Missing VSC metadata exception: \n".$message, $code, $previous); - } -} \ No newline at end of file