diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 260af566b..2ec21c33f 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -1356,7 +1356,7 @@ EOT } if ($targetVersion === null) { - if ($majorOnly && Preg::isMatch('{^(?P0\.)?(?P\d+)\.}', $package->getVersion(), $match)) { + if ($majorOnly && Preg::isMatch('{^(?P(?:0\.)+)?(?P\d+)\.}', $package->getVersion(), $match)) { $targetVersion = '>='.$match['zero_major'].($match['first_meaningful'] + 1).',<9999999-dev'; } diff --git a/tests/Composer/Test/Command/ShowCommandTest.php b/tests/Composer/Test/Command/ShowCommandTest.php index ea33377e3..9c9880203 100644 --- a/tests/Composer/Test/Command/ShowCommandTest.php +++ b/tests/Composer/Test/Command/ShowCommandTest.php @@ -199,6 +199,8 @@ outdated/patch 1.0.0 ! 1.0.1', 'packages' => [ 'type' => 'package', 'package' => [ + ['name' => 'zerozero/major', 'description' => 'generic description', 'version' => '0.0.1'], + ['name' => 'zerozero/major', 'description' => 'generic description', 'version' => '0.0.2'], ['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'], @@ -209,6 +211,7 @@ outdated/patch 1.0.0 ! 1.0.1', ], ], 'require' => [ + 'zerozero/major' => '^0.0.1', 'zero/major' => '^0.1', 'zero/minor' => '^0.1', 'zero/patch' => '^0.1', @@ -216,6 +219,7 @@ outdated/patch 1.0.0 ! 1.0.1', ]); $this->createInstalledJson([ + $this->getPackage('zerozero/major', '0.0.1'), $this->getPackage('zero/major', '0.1.0'), $this->getPackage('zero/minor', '0.1.0'), $this->getPackage('zero/patch', '0.1.2'), @@ -244,7 +248,8 @@ zero/patch 0.1.2 ! 0.1.2.1', trim($appTester->getDisplay( '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))); +zero/major 0.1.0 ~ 0.2.0 +zerozero/major 0.0.1 ~ 0.0.2', trim($appTester->getDisplay(true))); } public function testShowAllShowsAllSections(): void