From afa14124f3a9fdeafdc3c0f4fff97a02c3d27e10 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 3 Apr 2012 19:50:25 +0200 Subject: [PATCH] Make sure we fetch origin with tags before checking out a new version --- src/Composer/Downloader/GitDownloader.php | 2 +- tests/Composer/Test/Downloader/GitDownloaderTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 5bd05a46d..39fd3f71a 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -45,7 +45,7 @@ class GitDownloader extends VcsDownloader $ref = escapeshellarg($target->getSourceReference()); $path = escapeshellarg($path); $this->io->write(" Checking out ".$target->getSourceReference()); - $command = 'cd %s && git remote set-url origin %s && git fetch && git checkout %3$s && git reset --hard %3$s'; + $command = 'cd %s && git remote set-url origin %s && git fetch --tags origin && git checkout %3$s && git reset --hard %3$s'; $commandCallable = function($url) use ($ref, $path, $command) { return sprintf($command, $path, $url, $ref); diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 3decf991b..d392e3db6 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -89,7 +89,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($expectedGitCommand)) ->will($this->returnValue(0)); - $expectedGitCommand = $this->getCmd("cd 'composerPath' && git remote set-url --push origin 'git@github.com:composer/composer.git'"); + $expectedGitCommand = $this->getCmd("git remote set-url --push origin 'git@github.com:composer/composer.git'"); $processExecutor->expects($this->at(3)) ->method('execute') ->with($this->equalTo($expectedGitCommand)) @@ -139,7 +139,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase public function testUpdate() { - $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url origin 'git://github.com/composer/composer' && git fetch && git checkout 'ref' && git reset --hard 'ref'"); + $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url origin 'git://github.com/composer/composer' && git fetch --tags origin && git checkout 'ref' && git reset --hard 'ref'"); $expectedGitResetCommand = $this->getCmd("cd 'composerPath' && git status --porcelain"); $packageMock = $this->getMock('Composer\Package\PackageInterface'); @@ -168,7 +168,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase */ public function testUpdateThrowsRuntimeExceptionIfGitCommandFails() { - $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url origin 'git://github.com/composer/composer' && git fetch && git checkout 'ref' && git reset --hard 'ref'"); + $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url origin 'git://github.com/composer/composer' && git fetch --tags origin && git checkout 'ref' && git reset --hard 'ref'"); $expectedGitResetCommand = $this->getCmd("cd 'composerPath' && git status --porcelain"); $packageMock = $this->getMock('Composer\Package\PackageInterface');