From 4cac2caf7086b75da808a13449d3d10e54a8762f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 8 Jun 2013 16:41:34 +0200 Subject: [PATCH] Make sure cd call allows switching drives on windows, fixes #1971 --- src/Composer/Downloader/GitDownloader.php | 3 ++- tests/Composer/Test/Downloader/GitDownloaderTest.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 2eb40bb1b..d1c072ecf 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -30,7 +30,8 @@ class GitDownloader extends VcsDownloader $this->cleanEnv(); $ref = $package->getSourceReference(); - $command = 'git clone %s %s && cd %2$s && git remote add composer %1$s && git fetch composer'; + $flag = defined('PHP_WINDOWS_VERSION_MAJOR') ? '/D ' : ''; + $command = 'git clone %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer'; $this->io->write(" Cloning ".$ref); $commandCallable = function($url) use ($ref, $path, $command) { diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 2637c5e6a..2da584c03 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -300,6 +300,8 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase private function getCmd($cmd) { if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $cmd = str_replace('cd ', 'cd /D ', $cmd); + return strtr($cmd, "'", '"'); }