mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Treat default branch name as a non-feature-branch no matter what it is called
This commit is contained in:
parent
4682efcf77
commit
6f0e5996de
2 changed files with 117 additions and 12 deletions
|
@ -135,6 +135,64 @@ class VersionGuesserTest extends TestCase
|
|||
$this->assertEquals($commitHash, $versionArray['commit']);
|
||||
}
|
||||
|
||||
public function testGuessVersionReadsAndRespectsDefaultBranchAsNonFeatureBranch()
|
||||
{
|
||||
$commitHash = '03a15d220da53c52eddd5f32ffca64a7b3801bea';
|
||||
$anotherCommitHash = '13a15d220da53c52eddd5f32ffca64a7b3801bea';
|
||||
|
||||
$executor = $this->getMockBuilder('\\Composer\\Util\\ProcessExecutor')
|
||||
->setMethods(array('execute'))
|
||||
->disableArgumentCloning()
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$self = $this;
|
||||
|
||||
$executor
|
||||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash, $anotherCommitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$output = " arbitrary $commitHash Commit message\n* current $anotherCommitHash Another message\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$executor
|
||||
->expects($this->at(1))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git remote show origin', $command);
|
||||
$output = " HEAD branch: arbitrary\r\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$executor
|
||||
->expects($this->at(2))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output, $path) use ($self, $anotherCommitHash) {
|
||||
$self->assertEquals('git rev-list arbitrary..current', $command);
|
||||
$output = "$anotherCommitHash\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$config = new Config;
|
||||
$config->merge(array('repositories' => array('packagist' => false)));
|
||||
$guesser = new VersionGuesser($config, $executor, new VersionParser());
|
||||
$versionArray = $guesser->guessVersion(array('version' => 'self.version'), 'dummy/path');
|
||||
|
||||
$this->assertEquals("dev-arbitrary", $versionArray['version']);
|
||||
$this->assertEquals($anotherCommitHash, $versionArray['commit']);
|
||||
$this->assertEquals("dev-current", $versionArray['feature_version']);
|
||||
$this->assertEquals("dev-current", $versionArray['feature_pretty_version']);
|
||||
}
|
||||
|
||||
public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNaming()
|
||||
{
|
||||
$commitHash = '03a15d220da53c52eddd5f32ffca64a7b3801bea';
|
||||
|
@ -163,6 +221,17 @@ class VersionGuesserTest extends TestCase
|
|||
$executor
|
||||
->expects($this->at(1))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git remote show origin', $command);
|
||||
$output = " HEAD branch: foo\r\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$executor
|
||||
->expects($this->at(2))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output, $path) use ($self, $anotherCommitHash) {
|
||||
$self->assertEquals('git rev-list arbitrary..current', $command);
|
||||
$output = "$anotherCommitHash\n";
|
||||
|
@ -206,10 +275,19 @@ class VersionGuesserTest extends TestCase
|
|||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$executor
|
||||
->expects($this->at(1))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git remote show origin', $command);
|
||||
$output = " HEAD branch: foo\r\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
$executor
|
||||
->expects($this->at(2))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output, $path) use ($self, $anotherCommitHash) {
|
||||
$self->assertEquals('git rev-list latest-testing..current', $command);
|
||||
$output = "$anotherCommitHash\n";
|
||||
|
@ -378,10 +456,19 @@ class VersionGuesserTest extends TestCase
|
|||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$executor
|
||||
->expects($this->at(1))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git remote show origin', $command);
|
||||
$output = " HEAD branch: foo\r\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
$executor
|
||||
->expects($this->at(2))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git describe --exact-match --tags', $command);
|
||||
$output = "v2.0.5-alpha2";
|
||||
|
@ -419,10 +506,19 @@ class VersionGuesserTest extends TestCase
|
|||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$executor
|
||||
->expects($this->at(1))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git remote show origin', $command);
|
||||
$output = " HEAD branch: foo\r\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
$executor
|
||||
->expects($this->at(2))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git describe --exact-match --tags', $command);
|
||||
$output = '1.0.0';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue