Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display identifier when no release matches #341

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/commands/install/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/commands/outdated/OutdatedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/commands/selfupdate/SelfupdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
7 changes: 6 additions & 1 deletion src/commands/update/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
}
11 changes: 9 additions & 2 deletions src/services/phar/ReleaseSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/commands/composer/ComposerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down