From a1bc424a064b5eee7324f4fab8580c1038ced48a Mon Sep 17 00:00:00 2001 From: Alex <93376818+sashashura@users.noreply.github.com> Date: Sun, 28 Aug 2022 08:40:56 +0100 Subject: [PATCH 1/3] Update release.yml --- .github/workflows/release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0e1efd9d..2ed3941bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,11 +5,16 @@ on: tags: - "*" +permissions: + contents: read + env: COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist" jobs: build: + permissions: + contents: write # for actions/create-release to create a release name: Upload Release Asset runs-on: ubuntu-latest steps: From 13421f7d66ae8e824e9b821f2aee75772284cbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Mirtes?= Date: Fri, 26 Aug 2022 15:01:28 +0200 Subject: [PATCH 2/3] Config - always respect COMPOSER_DISCARD_CHANGES --- src/Composer/Config.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 141efa6ff..8d132bb7c 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -376,7 +376,8 @@ class Config return $value; 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)) { throw new \RuntimeException( "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 * that overload config values. * - * @return string|bool + * @return string|false */ private function getComposerEnv(string $var) { From 2d48c7dbb0660c014989319d927af7ca5578193e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 30 Aug 2022 20:45:07 +0200 Subject: [PATCH 3/3] Fix handling of zero-major versions in outdated --major-only flag, fixes #11032 --- src/Composer/Command/ShowCommand.php | 4 +- .../Composer/Test/Command/ShowCommandTest.php | 55 +++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index eca2149ae..260af566b 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -1356,8 +1356,8 @@ EOT } if ($targetVersion === null) { - if ($majorOnly && Preg::isMatch('{^(\d+)\.}', $package->getVersion(), $match)) { - $targetVersion = '>='.($match[1] + 1).',<9999999-dev'; + if ($majorOnly && Preg::isMatch('{^(?P0\.)?(?P\d+)\.}', $package->getVersion(), $match)) { + $targetVersion = '>='.$match['zero_major'].($match['first_meaningful'] + 1).',<9999999-dev'; } if ($minorOnly) { diff --git a/tests/Composer/Test/Command/ShowCommandTest.php b/tests/Composer/Test/Command/ShowCommandTest.php index ea23fad11..ea33377e3 100644 --- a/tests/Composer/Test/Command/ShowCommandTest.php +++ b/tests/Composer/Test/Command/ShowCommandTest.php @@ -192,6 +192,61 @@ outdated/patch 1.0.0 ! 1.0.1', } } + 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 ! 0.1.2.1', 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 ! 0.1.2 +zero/patch 0.1.2 ! 0.1.2.1', 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 { $this->initTempComposer([