Merge remote-tracking branch 'colinodell/fix-tag-ambiguity'

Conflicts:
	src/Composer/Downloader/GitDownloader.php
	tests/Composer/Test/Downloader/GitDownloaderTest.php
main
Jordi Boggiano 9 years ago
commit 0081964428

@ -220,7 +220,7 @@ class GitDownloader extends VcsDownloader
// Otherwise git tries the branch name as well as file name.
// If the non-existent branch is actually the name of a file, the file
// is checked out.
$template = 'git checkout %s -- && git reset --hard %1$s';
$template = 'git checkout %s -- && git reset --hard %1$s --';
$branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
$branches = null;
@ -234,7 +234,7 @@ class GitDownloader extends VcsDownloader
&& $branches
&& preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
) {
$command = sprintf('git checkout -B %s %s && git reset --hard %2$s', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
$command = sprintf('git checkout -B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
if (0 === $this->process->execute($command, $output, $path)) {
return;
}
@ -248,11 +248,11 @@ class GitDownloader extends VcsDownloader
}
$command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
$fallbackCommand = sprintf('git checkout -B %s %s', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
$fallbackCommand = sprintf('git checkout -B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
if (0 === $this->process->execute($command, $output, $path)
|| 0 === $this->process->execute($fallbackCommand, $output, $path)
) {
$command = sprintf('git reset --hard %s', ProcessExecutor::escape($reference));
$command = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
if (0 === $this->process->execute($command, $output, $path)) {
return;
}

@ -79,7 +79,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
$processExecutor->expects($this->at(3))
->method('execute')
->with($this->equalTo($this->winCompat("git reset --hard '1234567890123456789012345678901234567890'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
->with($this->equalTo($this->winCompat("git reset --hard '1234567890123456789012345678901234567890' --")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
->will($this->returnValue(0));
$downloader = $this->getDownloaderMock(null, null, $processExecutor);
@ -134,7 +134,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
$processExecutor->expects($this->at(6))
->method('execute')
->with($this->equalTo($this->winCompat("git checkout 'ref' -- && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
->with($this->equalTo($this->winCompat("git checkout 'ref' -- && git reset --hard 'ref' --")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
->will($this->returnValue(0));
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);
@ -266,7 +266,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(0));
$processExecutor->expects($this->at(4))
->method('execute')
->with($this->equalTo($this->winCompat("git checkout 'ref' -- && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat($tmpDir)))
->with($this->equalTo($this->winCompat("git checkout 'ref' -- && git reset --hard 'ref' --")), $this->equalTo(null), $this->equalTo($this->winCompat($tmpDir)))
->will($this->returnValue(0));
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);

Loading…
Cancel
Save