From 332a933e8b744901441f1e80b46f36c7e4f24f04 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 17 Oct 2014 16:32:48 +0100 Subject: [PATCH] Remove fallback on missing commit, fixes #3314, fixes #3147 --- src/Composer/Downloader/DownloadManager.php | 4 +-- src/Composer/Downloader/GitDownloader.php | 38 ++------------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 01ccc822b..3460026cf 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -192,7 +192,7 @@ class DownloadManager foreach ($sources as $i => $source) { if (isset($e)) { - $this->io->write('Now trying to download from ' . $source . ''); + $this->io->write(' Now trying to download from ' . $source . ''); } $package->setInstallationSource($source); try { @@ -207,7 +207,7 @@ class DownloadManager } $this->io->write( - 'Failed to download '. + ' Failed to download '. $package->getPrettyName(). ' from ' . $source . ': '. $e->getMessage().'' diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 0584f675a..503d792a1 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -256,42 +256,8 @@ class GitDownloader extends VcsDownloader } // reference was not found (prints "fatal: reference is not a tree: $ref") - if ($date && false !== strpos($this->process->getErrorOutput(), $reference)) { - $date = $date->format('U'); - - // guess which remote branch to look at first - $command = 'git branch -r'; - if (0 !== $this->process->execute($command, $output, $path)) { - throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); - } - - $guessTemplate = 'git log --until=%s --date=raw -n1 --pretty=%%H %s'; - foreach ($this->process->splitLines($output) as $line) { - if (preg_match('{^composer/'.preg_quote($branch).'(?:\.x)?$}i', trim($line))) { - // find the previous commit by date in the given branch - if (0 === $this->process->execute(sprintf($guessTemplate, $date, ProcessExecutor::escape(trim($line))), $output, $path)) { - $newReference = trim($output); - } - - break; - } - } - - if (empty($newReference)) { - // no matching branch found, find the previous commit by date in all commits - if (0 !== $this->process->execute(sprintf($guessTemplate, $date, '--all'), $output, $path)) { - throw new \RuntimeException('Failed to execute ' . GitUtil::sanitizeUrl($command) . "\n\n" . $this->process->getErrorOutput()); - } - $newReference = trim($output); - } - - // checkout the new recovered ref - $command = sprintf($template, ProcessExecutor::escape($newReference)); - if (0 === $this->process->execute($command, $output, $path)) { - $this->io->write(' '.$reference.' is gone (history was rewritten?), recovered by checking out '.$newReference); - - return $newReference; - } + if (false !== strpos($this->process->getErrorOutput(), $reference)) { + $this->io->write(' '.$reference.' is gone (history was rewritten?)'); } throw new \RuntimeException('Failed to execute ' . GitUtil::sanitizeUrl($command) . "\n\n" . $this->process->getErrorOutput());