Implemented interactive user confirmation on source package update failure
Removed unnecessary options for installation Removed unnecessary exceptionpull/4878/head
parent
581ce91f90
commit
e0fad1f55b
|
@ -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(<<<EOT
|
||||
|
@ -84,7 +83,6 @@ EOT
|
|||
|
||||
$composer = $this->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);
|
||||
|
|
|
@ -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 [<comment>yes</comment>]? ', true)) {
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 = "";
|
||||
|
|
|
@ -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('');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: bogdans
|
||||
* Date: 2/4/16
|
||||
* Time: 1:16 AM
|
||||
*/
|
||||
|
||||
namespace Composer\Downloader;
|
||||
|
||||
/**
|
||||
* Exception thrown when missing .git|.svn|.hg folders, which contain VSC metadata
|
||||
*
|
||||
* @author Bogdans Ozerkins <b.ozerkins@gmail.com>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue