From d347e1efca0439014ee8a31d292ff804b7e5dad5 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 13 Feb 2016 17:43:57 +0000 Subject: [PATCH] Minor tweaks refs #4878 --- src/Composer/Downloader/DownloadManager.php | 13 +++++++++---- src/Composer/Downloader/GitDownloader.php | 7 ++----- src/Composer/Downloader/HgDownloader.php | 6 +----- src/Composer/Downloader/PerforceDownloader.php | 6 +----- src/Composer/Downloader/SvnDownloader.php | 6 +----- src/Composer/Downloader/VcsDownloader.php | 2 +- 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 902e8beaf..2546e8c76 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -252,14 +252,19 @@ class DownloadManager $target->setInstallationSource($installationSource); try { $downloader->update($initial, $target, $targetDir); + return; - } catch (\RuntimeException $ex) { - if (!$this->io->isInteractive() || - !$this->io->askConfirmation(' Updating failed. Would you like to try reinstalling instead [yes]? ', true)) { - throw $ex; + } catch (\RuntimeException $e) { + if (!$this->io->isInteractive()) { + throw $e; + } + $this->io->writeError(' Update failed ('.$e->getMessage().')'); + if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [yes]? ', true)) { + throw $e; } } } + $downloader->remove($initial, $targetDir); $this->download($target, $targetDir, 'source' === $installationSource); } diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index c1d47c794..93beee158 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -372,15 +372,12 @@ class GitDownloader extends VcsDownloader } /** - * Checks if VCS metadata repository has been initialized - * repository example: .git|.svn|.hg - * - * @param string $path - * @return bool + * {@inheritDoc} */ protected function hasMetadataRepository($path) { $path = $this->normalizePath($path); + return is_dir($path.'/.git'); } } diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php index 9c379a9e5..419ce92cb 100644 --- a/src/Composer/Downloader/HgDownloader.php +++ b/src/Composer/Downloader/HgDownloader.php @@ -86,11 +86,7 @@ class HgDownloader extends VcsDownloader } /** - * Checks if VCS metadata repository has been initialized - * repository example: .git|.svn|.hg - * - * @param string $path - * @return bool + * {@inheritDoc} */ protected function hasMetadataRepository($path) { diff --git a/src/Composer/Downloader/PerforceDownloader.php b/src/Composer/Downloader/PerforceDownloader.php index 77f82ac1e..0acc60f84 100644 --- a/src/Composer/Downloader/PerforceDownloader.php +++ b/src/Composer/Downloader/PerforceDownloader.php @@ -106,11 +106,7 @@ class PerforceDownloader extends VcsDownloader } /** - * Checks if VCS metadata repository has been initialized - * repository example: .git|.svn|.hg - * - * @param string $path - * @return bool + * {@inheritDoc} */ protected function hasMetadataRepository($path) { diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php index 42ebf758e..b71e22b31 100644 --- a/src/Composer/Downloader/SvnDownloader.php +++ b/src/Composer/Downloader/SvnDownloader.php @@ -190,11 +190,7 @@ class SvnDownloader extends VcsDownloader } /** - * Checks if VCS metadata repository has been initialized - * repository example: .git|.svn|.hg - * - * @param string $path - * @return bool + * {@inheritDoc} */ protected function hasMetadataRepository($path) { diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index 37aa9042f..0a48708d2 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -133,7 +133,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa // 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)) { + if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) { $message = 'Pulling in changes:'; $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);