From 40095d980c5f20b77b5311400b69adb878bd1bce Mon Sep 17 00:00:00 2001 From: Sandy Pleyte Date: Thu, 20 Feb 2014 16:26:34 +0100 Subject: [PATCH] Fix for #2494, don't retrieve svn log when the references don't contain a reference number. --- src/Composer/Downloader/SvnDownloader.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php index ec789c92a..0ff5a0ede 100644 --- a/src/Composer/Downloader/SvnDownloader.php +++ b/src/Composer/Downloader/SvnDownloader.php @@ -144,14 +144,20 @@ class SvnDownloader extends VcsDownloader */ protected function getCommitLogs($fromReference, $toReference, $path) { - // strip paths from references and only keep the actual revision - $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference); - $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference); + if (preg_match('{.*@(\d+)$}', $fromReference) && preg_match('{.*@(\d+)$}', $toReference) ) { + // strip paths from references and only keep the actual revision + $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference); + $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference); - $command = sprintf('svn log -r%s:%s --incremental', $fromRevision, $toRevision); + $command = sprintf('svn log -r%s:%s --incremental', $fromRevision, $toRevision); - if (0 !== $this->process->execute($command, $output, $path)) { - throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); + if (0 !== $this->process->execute($command, $output, $path)) { + throw new \RuntimeException( + 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput() + ); + } + } else { + $output = "Couldn't retrieve changes with reference $fromReference:$toReference"; } return $output;