Merge branch '1.10'
commit
03b8c3db3f
|
@ -83,16 +83,16 @@
|
|||
},
|
||||
{
|
||||
"name": "composer/semver",
|
||||
"version": "3.2.0",
|
||||
"version": "3.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/semver.git",
|
||||
"reference": "da7ce661431b17a71271cdf7f5437dc722133123"
|
||||
"reference": "ebb714493b3a54f1dbbec6b15ab7bc9b3440e17b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/semver/zipball/da7ce661431b17a71271cdf7f5437dc722133123",
|
||||
"reference": "da7ce661431b17a71271cdf7f5437dc722133123",
|
||||
"url": "https://api.github.com/repos/composer/semver/zipball/ebb714493b3a54f1dbbec6b15ab7bc9b3440e17b",
|
||||
"reference": "ebb714493b3a54f1dbbec6b15ab7bc9b3440e17b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -144,7 +144,7 @@
|
|||
"support": {
|
||||
"irc": "irc://irc.freenode.org/composer",
|
||||
"issues": "https://github.com/composer/semver/issues",
|
||||
"source": "https://github.com/composer/semver/tree/3.2.0"
|
||||
"source": "https://github.com/composer/semver/tree/3.2.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -160,7 +160,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-09-09T09:39:19+00:00"
|
||||
"time": "2020-09-27T13:14:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/spdx-licenses",
|
||||
|
|
|
@ -172,7 +172,7 @@ EOT
|
|||
$io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
|
||||
}
|
||||
|
||||
$io->write(sprintf('OpenSSL version: <comment>%s</comment>', OPENSSL_VERSION_TEXT));
|
||||
$io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
|
||||
|
||||
return $this->exitCode;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class StatusCommand extends BaseCommand
|
|||
{
|
||||
$this
|
||||
->setName('status')
|
||||
->setDescription('Shows a list of locally modified packages, for packages installed from source.')
|
||||
->setDescription('Shows a list of locally modified packages.')
|
||||
->setDefinition(array(
|
||||
new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
|
||||
))
|
||||
|
|
|
@ -120,7 +120,7 @@ class VersionGuesser
|
|||
$isDetached = false;
|
||||
|
||||
// try to fetch current version from git branch
|
||||
if (0 === $this->process->execute('git branch --no-color --no-abbrev -v', $output, $path)) {
|
||||
if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
|
||||
$branches = array();
|
||||
$isFeatureBranch = false;
|
||||
|
||||
|
@ -147,8 +147,8 @@ class VersionGuesser
|
|||
}
|
||||
}
|
||||
|
||||
if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
|
||||
if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
|
||||
if ($branch && !preg_match('{^ *.+/HEAD }', $branch)) {
|
||||
if (preg_match('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
|
||||
$branches[] = $match[1];
|
||||
}
|
||||
}
|
||||
|
@ -252,13 +252,25 @@ class VersionGuesser
|
|||
return array('version' => $version, 'pretty_version' => $prettyVersion);
|
||||
}
|
||||
|
||||
// sort numeric branches below named ones, to make sure if the branch has the same distance from main and 1.10 and 1.9 for example, main is picked
|
||||
// sort local branches first then remote ones
|
||||
// and sort numeric branches below named ones, to make sure if the branch has the same distance from main and 1.10 and 1.9 for example, main is picked
|
||||
// and sort using natural sort so that 1.10 will appear before 1.9
|
||||
rsort($branches, defined('SORT_NATURAL') ? SORT_NATURAL : SORT_REGULAR);
|
||||
usort($branches, function ($a, $b) {
|
||||
$aRemote = 0 === strpos($a, 'remotes/');
|
||||
$bRemote = 0 === strpos($b, 'remotes/');
|
||||
|
||||
if ($aRemote !== $bRemote) {
|
||||
return $aRemote ? 1 : -1;
|
||||
}
|
||||
|
||||
return strnatcasecmp($b, $a);
|
||||
});
|
||||
|
||||
foreach ($branches as $candidate) {
|
||||
$candidateVersion = preg_replace('{^remotes/\S+/}', '', $candidate);
|
||||
|
||||
// do not compare against itself or other feature branches
|
||||
if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidate)) {
|
||||
if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -269,8 +281,11 @@ class VersionGuesser
|
|||
|
||||
if (strlen($output) < $length) {
|
||||
$length = strlen($output);
|
||||
$version = $this->versionParser->normalizeBranch($candidate);
|
||||
$prettyVersion = 'dev-' . $candidate;
|
||||
$version = $this->versionParser->normalizeBranch($candidateVersion);
|
||||
$prettyVersion = 'dev-' . $candidateVersion;
|
||||
if ($length === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ class RootPackageLoaderTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* latest-production 38137d2f6c70e775e137b2d8a7a7d3eaebf7c7e5 Commit message\n master 4f6ed96b0bc363d2aa4404c3412de1c011f67c66 Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -187,7 +187,7 @@ class RootPackageLoaderTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* latest-production 38137d2f6c70e775e137b2d8a7a7d3eaebf7c7e5 Commit message\n master 4f6ed96b0bc363d2aa4404c3412de1c011f67c66 Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -48,7 +48,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at($step))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
|
||||
return 128;
|
||||
})
|
||||
|
@ -116,7 +116,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash, $anotherCommitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* master $commitHash Commit message\n(no branch) $anotherCommitHash Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -154,7 +154,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash, $anotherCommitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = " arbitrary $commitHash Commit message\n* current $anotherCommitHash Another message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -188,7 +188,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash, $anotherCommitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = " arbitrary $commitHash Commit message\n* feature $anotherCommitHash Another message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -235,7 +235,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash, $anotherCommitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = " latest-testing $commitHash Commit message\n* feature $anotherCommitHash Another message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -281,7 +281,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash, $anotherCommitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* latest-testing $commitHash Commit message\n current $anotherCommitHash Another message\n master $anotherCommitHash Another message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -316,7 +316,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* (no branch) $commitHash Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -347,7 +347,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* (HEAD detached at FETCH_HEAD) $commitHash Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -377,7 +377,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* (HEAD detached at 03a15d220) $commitHash Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -406,7 +406,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* (HEAD detached at v2.0.5-alpha2) 433b98d4218c181bae01865901aac045585e8a1a Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -446,7 +446,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* (HEAD detached at 1.0.0) c006f0c12bbbf197b5c071ffb1c0e9812bb14a4d Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -487,7 +487,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* foo 03a15d220da53c52eddd5f32ffca64a7b3801bea Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -517,7 +517,7 @@ class VersionGuesserTest extends TestCase
|
|||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* 1.5 03a15d220da53c52eddd5f32ffca64a7b3801bea Commit message\n";
|
||||
|
||||
return 0;
|
||||
|
@ -532,4 +532,46 @@ class VersionGuesserTest extends TestCase
|
|||
$this->assertEquals("1.5.x-dev", $versionData['pretty_version']);
|
||||
$this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']);
|
||||
}
|
||||
|
||||
public function testRemoteBranchesAreSelected()
|
||||
{
|
||||
$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) {
|
||||
$self->assertEquals('git branch -a --no-color --no-abbrev -v', $command);
|
||||
$output = "* feature-branch 03a15d220da53c52eddd5f32ffca64a7b3801bea Commit message\n".
|
||||
"remotes/origin/1.5 03a15d220da53c52eddd5f32ffca64a7b3801bea Commit message\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$executor
|
||||
->expects($this->at(1))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output, $path) use ($self) {
|
||||
$self->assertEquals('git rev-list remotes/origin/1.5..feature-branch', $command);
|
||||
$output = "\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
|
||||
$config = new Config;
|
||||
$config->merge(array('repositories' => array('packagist' => false)));
|
||||
$guesser = new VersionGuesser($config, $executor, new VersionParser());
|
||||
$versionData = $guesser->guessVersion(array('version' => 'self.version'), 'dummy/path');
|
||||
$this->assertEquals("1.5.x-dev", $versionData['pretty_version']);
|
||||
$this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class VcsRepositoryTest extends TestCase
|
|||
self::$gitRepo = $this->getUniqueTmpDirectory();
|
||||
|
||||
if (!@chdir(self::$gitRepo)) {
|
||||
$this->skipped = 'Could not create and move into the temp git repo '.self::$gitRepo;
|
||||
$this->skipped = 'Could not move into the temp git repo '.self::$gitRepo;
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue