diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 3ae00c228..6763d24d6 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -48,6 +48,7 @@ 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 4d2e9c8f4..684b64111 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -26,6 +26,7 @@ class DownloadManager private $io; private $preferDist = false; private $preferSource = false; + private $forceUpdate = false; private $filesystem; private $downloaders = array(); @@ -69,6 +70,20 @@ 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 @@ -250,11 +265,17 @@ class DownloadManager if ($initialType === $targetType) { $target->setInstallationSource($installationSource); - $downloader->update($initial, $target, $targetDir); - } else { - $downloader->remove($initial, $targetDir); - $this->download($target, $targetDir, 'source' === $installationSource); + try { + $downloader->update($initial, $target, $targetDir); + return; + } catch (VcsMissingMetadataException $ex) { + if ($this->forceUpdate === false) { + throw $ex; + } + } } + $downloader->remove($initial, $targetDir); + $this->download($target, $targetDir, 'source' === $installationSource); } /**