Fix tests and run it before the push url updater
parent
fb1747624c
commit
a309e1d89d
|
@ -52,6 +52,10 @@ class GitDownloader extends VcsDownloader
|
||||||
};
|
};
|
||||||
|
|
||||||
$this->gitUtil->runCommand($commandCallable, $url, $path, true);
|
$this->gitUtil->runCommand($commandCallable, $url, $path, true);
|
||||||
|
if ($url !== $package->getSourceUrl()) {
|
||||||
|
$url = $package->getSourceUrl();
|
||||||
|
$this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
|
||||||
|
}
|
||||||
$this->setPushUrl($path, $url);
|
$this->setPushUrl($path, $url);
|
||||||
|
|
||||||
if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
|
if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
|
||||||
|
@ -60,10 +64,6 @@ class GitDownloader extends VcsDownloader
|
||||||
}
|
}
|
||||||
$package->setSourceReference($newRef);
|
$package->setSourceReference($newRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($url !== $package->getSourceUrl()) {
|
|
||||||
$this->process->execute(sprintf('git remote set-url origin %s', $package->getSourceUrl()), $output, $path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,6 +53,9 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getSourceUrls')
|
->method('getSourceUrls')
|
||||||
->will($this->returnValue(array('https://example.com/composer/composer')));
|
->will($this->returnValue(array('https://example.com/composer/composer')));
|
||||||
|
$packageMock->expects($this->any())
|
||||||
|
->method('getSourceUrl')
|
||||||
|
->will($this->returnValue('https://example.com/composer/composer'));
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getPrettyVersion')
|
->method('getPrettyVersion')
|
||||||
->will($this->returnValue('dev-master'));
|
->will($this->returnValue('dev-master'));
|
||||||
|
@ -91,36 +94,45 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
->will($this->returnValue('ref'));
|
->will($this->returnValue('ref'));
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getSourceUrls')
|
->method('getSourceUrls')
|
||||||
->will($this->returnValue(array('https://github.com/composer/composer')));
|
->will($this->returnValue(array('https://github.com/mirrors/composer', 'https://github.com/composer/composer')));
|
||||||
|
$packageMock->expects($this->any())
|
||||||
|
->method('getSourceUrl')
|
||||||
|
->will($this->returnValue('https://github.com/composer/composer'));
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getPrettyVersion')
|
->method('getPrettyVersion')
|
||||||
->will($this->returnValue('1.0.0'));
|
->will($this->returnValue('1.0.0'));
|
||||||
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||||
|
|
||||||
$expectedGitCommand = $this->winCompat("git clone --no-checkout 'git://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'git://github.com/composer/composer' && git fetch composer");
|
$expectedGitCommand = $this->winCompat("git clone --no-checkout 'git://github.com/mirrors/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'git://github.com/mirrors/composer' && git fetch composer");
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand))
|
->with($this->equalTo($expectedGitCommand))
|
||||||
->will($this->returnValue(1));
|
->will($this->returnValue(1));
|
||||||
|
|
||||||
$expectedGitCommand = $this->winCompat("git clone --no-checkout 'https://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'https://github.com/composer/composer' && git fetch composer");
|
$expectedGitCommand = $this->winCompat("git clone --no-checkout 'https://github.com/mirrors/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'https://github.com/mirrors/composer' && git fetch composer");
|
||||||
$processExecutor->expects($this->at(2))
|
$processExecutor->expects($this->at(2))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand))
|
->with($this->equalTo($expectedGitCommand))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
$expectedGitCommand = $this->winCompat("git remote set-url --push origin 'git@github.com:composer/composer.git'");
|
$expectedGitCommand = $this->winCompat("git remote set-url origin 'https://github.com/composer/composer'");
|
||||||
$processExecutor->expects($this->at(3))
|
$processExecutor->expects($this->at(3))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
|
$expectedGitCommand = $this->winCompat("git remote set-url --push origin 'git@github.com:composer/composer.git'");
|
||||||
$processExecutor->expects($this->at(4))
|
$processExecutor->expects($this->at(4))
|
||||||
|
->method('execute')
|
||||||
|
->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
||||||
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
|
$processExecutor->expects($this->at(5))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo('git branch -r'))
|
->with($this->equalTo('git branch -r'))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
$processExecutor->expects($this->at(5))
|
$processExecutor->expects($this->at(6))
|
||||||
->method('execute')
|
->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));
|
->will($this->returnValue(0));
|
||||||
|
@ -149,6 +161,9 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getSourceUrls')
|
->method('getSourceUrls')
|
||||||
->will($this->returnValue(array('https://github.com/composer/composer')));
|
->will($this->returnValue(array('https://github.com/composer/composer')));
|
||||||
|
$packageMock->expects($this->any())
|
||||||
|
->method('getSourceUrl')
|
||||||
|
->will($this->returnValue('https://github.com/composer/composer'));
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getPrettyVersion')
|
->method('getPrettyVersion')
|
||||||
->will($this->returnValue('1.0.0'));
|
->will($this->returnValue('1.0.0'));
|
||||||
|
|
Loading…
Reference in New Issue