Skip to content

Commit

Permalink
fix: resolve getCurrentRemoteVersion() when latest is unstable (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny authored Sep 1, 2023
1 parent b56bfc0 commit 8bb46cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Strategy/GithubStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ public function getCurrentRemoteVersion(Updater $updater)
* Setup remote URL if there's an actual version to download.
*/
if (! empty($this->remoteVersion)) {
$chosenVersion = array_filter($package['packages'][$this->getPackageName()], function (array $package) {
$remoteVersionPackages = array_filter($package['packages'][$this->getPackageName()], function (array $package) {
return $package['version'] === $this->remoteVersion;
})[0];
});
$chosenVersion = reset($remoteVersionPackages);

$this->remoteUrl = $this->getDownloadUrl($chosenVersion);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ private function createTestPharAndKey(): void
file_put_contents($this->tmp.'/packages.json', json_encode([
'packages' => [
'humbug/test-phar' => [
[
'version' => '2.0.0-beta.1',
],
[
'version' => '1.0.1',
'source' => [
Expand Down

0 comments on commit 8bb46cf

Please sign in to comment.