diff --git a/src/commands/install/InstallCommand.php b/src/commands/install/InstallCommand.php index 659ab26e..9e3503fc 100644 --- a/src/commands/install/InstallCommand.php +++ b/src/commands/install/InstallCommand.php @@ -62,7 +62,12 @@ private function resolveToRelease(RequestedPhar $requestedPhar): SupportedReleas $repository = $this->pharResolver->resolve($requestedPhar); $releases = $repository->getReleasesByRequestedPhar($requestedPhar); - return $this->selector->select($releases, $requestedPhar->getLockedVersion(), $this->config->forceAcceptUnsignedPhars()); + return $this->selector->select( + $requestedPhar->getIdentifier(), + $releases, + $requestedPhar->getLockedVersion(), + $this->config->forceAcceptUnsignedPhars() + ); } private function getDestination(string $pharName, RequestedPhar $requestedPhar, Directory $destination): Filename { diff --git a/src/commands/outdated/OutdatedCommand.php b/src/commands/outdated/OutdatedCommand.php index c8b98d75..68cdf6ec 100644 --- a/src/commands/outdated/OutdatedCommand.php +++ b/src/commands/outdated/OutdatedCommand.php @@ -138,7 +138,12 @@ private function resolveToRelease(RequestedPhar $requestedPhar): SupportedReleas $repository = $this->pharResolver->resolve($requestedPhar); $releases = $repository->getReleasesByRequestedPhar($requestedPhar); - return $this->selector->select($releases, $requestedPhar->getVersionConstraint(), true); + return $this->selector->select( + $requestedPhar->getIdentifier(), + $releases, + $requestedPhar->getVersionConstraint(), + true + ); } private function renderJsonOutput(array $outdated): string { diff --git a/src/commands/selfupdate/SelfupdateCommand.php b/src/commands/selfupdate/SelfupdateCommand.php index c58d2bcf..f91c4747 100644 --- a/src/commands/selfupdate/SelfupdateCommand.php +++ b/src/commands/selfupdate/SelfupdateCommand.php @@ -68,7 +68,12 @@ public function execute(): void { $repository = $this->gitHubAliasResolver->resolve($requestedPhar); $releases = $repository->getReleasesByRequestedPhar($requestedPhar); - $release = $this->selector->select($releases, $requestedPhar->getVersionConstraint(), false); + $release = $this->selector->select( + $requestedPhar->getIdentifier(), + $releases, + $requestedPhar->getVersionConstraint(), + false + ); if (!$release->getVersion()->isGreaterThan(new Version($this->currentPhiveVersion->getVersion()))) { $this->output->writeInfo('You already have the newest version of PHIVE.'); diff --git a/src/commands/update/UpdateCommand.php b/src/commands/update/UpdateCommand.php index 1f80adac..9bad2387 100644 --- a/src/commands/update/UpdateCommand.php +++ b/src/commands/update/UpdateCommand.php @@ -58,6 +58,11 @@ private function resolveToRelease(RequestedPhar $requestedPhar): SupportedReleas $repository = $this->pharResolver->resolve($requestedPhar); $releases = $repository->getReleasesByRequestedPhar($requestedPhar); - return $this->selector->select($releases, $requestedPhar->getVersionConstraint(), $this->config->forceAcceptUnsignedPhars()); + return $this->selector->select( + $requestedPhar->getIdentifier(), + $releases, + $requestedPhar->getVersionConstraint(), + $this->config->forceAcceptUnsignedPhars() + ); } } diff --git a/src/services/phar/ReleaseSelector.php b/src/services/phar/ReleaseSelector.php index cf8375bb..d8e776e9 100644 --- a/src/services/phar/ReleaseSelector.php +++ b/src/services/phar/ReleaseSelector.php @@ -28,7 +28,12 @@ public function __construct(Output $output) { /** * @throws ReleaseException */ - public function select(ReleaseCollection $releases, VersionConstraint $versionConstraint, bool $acceptUnsigned): SupportedRelease { + public function select( + PharIdentifier $identifier, + ReleaseCollection $releases, + VersionConstraint $versionConstraint, + bool $acceptUnsigned + ): SupportedRelease { /** @var null|Release $latest */ $latest = null; @@ -70,7 +75,9 @@ public function select(ReleaseCollection $releases, VersionConstraint $versionCo } if ($latest === null) { - throw new ReleaseException('No matching release found!'); + throw new ReleaseException( + sprintf('No matching release found for %s!', $identifier->asString()) + ); } return $latest; diff --git a/tests/unit/commands/composer/ComposerCommandTest.php b/tests/unit/commands/composer/ComposerCommandTest.php index 236dc363..e021fc1d 100644 --- a/tests/unit/commands/composer/ComposerCommandTest.php +++ b/tests/unit/commands/composer/ComposerCommandTest.php @@ -13,6 +13,7 @@ use PharIo\FileSystem\Directory; use PharIo\FileSystem\Filename; use PharIo\Phive\Cli\Input; +use PharIo\Phive\PharAlias; use PharIo\Version\ExactVersionConstraint; use PHPUnit\Framework\TestCase; use PHPUnit_Framework_MockObject_MockObject; @@ -85,6 +86,7 @@ public function testDoesInstallsCandidateIfInstallationWasConfirmend(): void { $requestedPhar->method('getVersionConstraint')->willReturn(new ExactVersionConstraint('1.0.0')); $requestedPhar->method('hasLocation')->willReturn(true); $requestedPhar->method('getLocation')->willReturn(new Filename('destination/foo.phar')); + $requestedPhar->method('getIdentifier')->willReturn(new PharAlias('Foo')); $this->composerService->method('findCandidates')->willReturn([$requestedPhar]); $this->input->method('confirm')->willReturn(true);