From eb283b34e40c087226e83e18fc9960012080d0c9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 10 Jul 2012 19:27:02 +0200 Subject: [PATCH] Revert "Fix git checkouts of custom branches, fixes #889" This reverts commit cbf27bb422b63de3c25a43aeb33768822a45f613. --- src/Composer/Downloader/GitDownloader.php | 6 ++---- tests/Composer/Test/Downloader/GitDownloaderTest.php | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 864465215..0bf8e65ac 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -67,8 +67,7 @@ class GitDownloader extends VcsDownloader { $template = 'git checkout %s && git reset --hard %1$s'; - $gitRef = preg_match('{^[a-f0-9]{40}$}', $reference) ? $reference : 'composer/'.$reference; - $command = sprintf($template, escapeshellarg($gitRef)); + $command = sprintf($template, escapeshellarg($reference)); if (0 === $this->process->execute($command, $output, $path)) { return; } @@ -105,8 +104,7 @@ class GitDownloader extends VcsDownloader } // checkout the new recovered ref - $gitRef = preg_match('{^[a-f0-9]{40}$}', $reference) ? $reference : 'composer/'.$reference; - $command = sprintf($template, escapeshellarg($gitRef)); + $command = sprintf($template, escapeshellarg($newReference)); if (0 === $this->process->execute($command, $output, $path)) { $this->io->write(' '.$reference.' is gone (history was rewritten?), recovered by checking out '.$newReference); diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 55f84618e..639913498 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -58,7 +58,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase $processExecutor->expects($this->at(1)) ->method('execute') - ->with($this->equalTo($this->getCmd("git checkout 'composer/ref' && git reset --hard 'composer/ref'")), $this->equalTo(null), $this->equalTo('composerPath')) + ->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath')) ->will($this->returnValue(0)); $downloader = $this->getDownloaderMock(null, $processExecutor); @@ -102,7 +102,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase $processExecutor->expects($this->at(6)) ->method('execute') - ->with($this->equalTo($this->getCmd("git checkout 'composer/ref' && git reset --hard 'composer/ref'")), $this->equalTo(null), $this->equalTo('composerPath')) + ->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath')) ->will($this->returnValue(0)); $downloader = $this->getDownloaderMock(null, $processExecutor); @@ -174,7 +174,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(0)); $processExecutor->expects($this->at(3)) ->method('execute') - ->with($this->equalTo($this->getCmd("git checkout 'composer/ref' && git reset --hard 'composer/ref'")), $this->equalTo(null), $this->equalTo('composerPath')) + ->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath')) ->will($this->returnValue(0)); $downloader = $this->getDownloaderMock(null, $processExecutor);