1
0
Fork 0

Merge branch '2.4'

pull/11043/head
Jordi Boggiano 2022-08-30 20:47:34 +02:00
commit 7e0ac53fc4
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
4 changed files with 65 additions and 4 deletions

View File

@ -5,11 +5,16 @@ on:
tags: tags:
- "*" - "*"
permissions:
contents: read
env: env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist" COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist"
jobs: jobs:
build: build:
permissions:
contents: write # for actions/create-release to create a release
name: Upload Release Asset name: Upload Release Asset
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -1356,8 +1356,8 @@ EOT
} }
if ($targetVersion === null) { if ($targetVersion === null) {
if ($majorOnly && Preg::isMatch('{^(\d+)\.}', $package->getVersion(), $match)) { if ($majorOnly && Preg::isMatch('{^(?P<zero_major>0\.)?(?P<first_meaningful>\d+)\.}', $package->getVersion(), $match)) {
$targetVersion = '>='.($match[1] + 1).',<9999999-dev'; $targetVersion = '>='.$match['zero_major'].($match['first_meaningful'] + 1).',<9999999-dev';
} }
if ($minorOnly) { if ($minorOnly) {

View File

@ -376,7 +376,8 @@ class Config
return $value; return $value;
case 'discard-changes': case 'discard-changes':
if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) { $env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES');
if ($env !== false) {
if (!in_array($env, ['stash', 'true', 'false', '1', '0'], true)) { if (!in_array($env, ['stash', 'true', 'false', '1', '0'], true)) {
throw new \RuntimeException( throw new \RuntimeException(
"Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash" "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
@ -519,7 +520,7 @@ class Config
* This should be used to read COMPOSER_ environment variables * This should be used to read COMPOSER_ environment variables
* that overload config values. * that overload config values.
* *
* @return string|bool * @return string|false
*/ */
private function getComposerEnv(string $var) private function getComposerEnv(string $var)
{ {

View File

@ -192,6 +192,61 @@ outdated/patch 1.0.0 <highlight>! 1.0.1</highlight>',
} }
} }
public function testOutdatedWithZeroMajor(): void
{
$this->initTempComposer([
'repositories' => [
'packages' => [
'type' => 'package',
'package' => [
['name' => 'zero/major', 'description' => 'generic description', 'version' => '0.1.0'],
['name' => 'zero/major', 'description' => 'generic description', 'version' => '0.2.0'],
['name' => 'zero/minor', 'description' => 'generic description', 'version' => '0.1.0'],
['name' => 'zero/minor', 'description' => 'generic description', 'version' => '0.1.2'],
['name' => 'zero/patch', 'description' => 'generic description', 'version' => '0.1.2'],
['name' => 'zero/patch', 'description' => 'generic description', 'version' => '0.1.2.1'],
],
],
],
'require' => [
'zero/major' => '^0.1',
'zero/minor' => '^0.1',
'zero/patch' => '^0.1',
],
]);
$this->createInstalledJson([
$this->getPackage('zero/major', '0.1.0'),
$this->getPackage('zero/minor', '0.1.0'),
$this->getPackage('zero/patch', '0.1.2'),
]);
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'outdated', '--direct' => true, '--patch-only' => true]);
self::assertSame(
'Legend:
! patch or minor release available - update recommended
~ major release available - update possible
zero/patch 0.1.2 <highlight>! 0.1.2.1</highlight>', trim($appTester->getDisplay(true)));
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'outdated', '--direct' => true, '--minor-only' => true]);
self::assertSame(
'Legend:
! patch or minor release available - update recommended
~ major release available - update possible
zero/minor 0.1.0 <highlight>! 0.1.2 </highlight>
zero/patch 0.1.2 <highlight>! 0.1.2.1</highlight>', trim($appTester->getDisplay(true)));
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'outdated', '--direct' => true, '--major-only' => true]);
self::assertSame(
'Legend:
! patch or minor release available - update recommended
~ major release available - update possible
zero/major 0.1.0 ~ 0.2.0', trim($appTester->getDisplay(true)));
}
public function testShowAllShowsAllSections(): void public function testShowAllShowsAllSections(): void
{ {
$this->initTempComposer([ $this->initTempComposer([