Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 3ec844a

Browse files
author
Holger Lösken
committed
Fix wrong url for getting tags/releases
1 parent ac7d705 commit 3ec844a

File tree

7 files changed

+634
-56
lines changed

7 files changed

+634
-56
lines changed

src/Contracts/GithubRepositoryTypeContract.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
interface GithubRepositoryTypeContract extends SourceRepositoryTypeContract
88
{
99
const GITHUB_API_URL = 'https://api.github.com';
10-
const GITHUB_URL = 'https://github.com';
1110
}

src/SourceRepositoryTypes/GithubRepositoryTypes/GithubTagType.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getVersionAvailable(string $prepend = '', string $append = ''):
5757
$response = $this->getRepositoryReleases();
5858

5959
$releaseCollection = collect(json_decode($response->getBody()->getContents()));
60-
$version = $prepend.$releaseCollection->first()->name.$append;
60+
$version = $prepend.$releaseCollection->first()->tag_name.$append;
6161
}
6262

6363
return $version;
@@ -83,8 +83,8 @@ public function fetch($version = ''): Release
8383

8484
$release = $this->selectRelease($releases, $version);
8585

86-
$this->release->setVersion($release->name)
87-
->setRelease($release->name.'.zip')
86+
$this->release->setVersion($release->tag_name)
87+
->setRelease($release->tag_name.'.zip')
8888
->updateStoragePath()
8989
->setDownloadUrl($release->zipball_url);
9090

@@ -101,8 +101,8 @@ public function selectRelease(Collection $collection, string $version)
101101
$release = $collection->first();
102102

103103
if (! empty($version)) {
104-
if ($collection->contains('name', $version)) {
105-
$release = $collection->where('name', $version)->first();
104+
if ($collection->contains('tag_name', $version)) {
105+
$release = $collection->where('tag_name', $version)->first();
106106
} else {
107107
Log::info('No release for version "'.$version.'" found. Selecting latest.');
108108
}
@@ -115,7 +115,7 @@ protected function getRepositoryReleases(): ResponseInterface
115115
{
116116
$url = '/repos/'.$this->config['repository_vendor']
117117
.'/'.$this->config['repository_name']
118-
.'/tags';
118+
.'/releases';
119119

120120
$headers = [];
121121

src/UpdaterServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected function registerManager()
120120
$this->app->bind(GithubTagType::class, function (): GithubRepositoryTypeContract {
121121
return new GithubTagType(
122122
config('self-update.repository_types.github'),
123-
new Client(['base_uri' => GithubRepositoryTypeContract::GITHUB_URL]),
123+
new Client(['base_uri' => GithubRepositoryTypeContract::GITHUB_API_URL]),
124124
$this->app->make(UpdateExecutor::class)
125125
);
126126
});

tests/Commands/CheckUpdateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function it_can_run_check_update_command_without_new_version_available():
3030

3131
$github->deleteVersionFile();
3232

33-
config(['self-update.version_installed' => 'v3.5']);
33+
config(['self-update.version_installed' => '3.5']);
3434

3535
$this->artisan(CheckForUpdate::class)
3636
->expectsOutput('There\'s no new version available.')

tests/Data/releases-tag.json

Lines changed: 615 additions & 36 deletions
Large diffs are not rendered by default.

tests/SourceRepositoryTypes/GithubRepositoryTypeTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ public function it_can_get_new_version_available_from_type_tag_without_version_f
118118

119119
Event::fake();
120120

121-
$this->assertFalse($github->isNewVersionAvailable('v2.7'));
122-
$this->assertTrue($github->isNewVersionAvailable('v1.1'));
121+
$this->assertFalse($github->isNewVersionAvailable('2.7'));
122+
$this->assertTrue($github->isNewVersionAvailable('1.1'));
123123

124124
Event::assertDispatched(UpdateAvailable::class, 1);
125125
Event::assertDispatched(UpdateAvailable::class, function (UpdateAvailable $e) use ($github) {
@@ -204,8 +204,8 @@ public function it_can_fetch_github_tag_releases_latest(): void
204204
$release = $github->fetch();
205205

206206
$this->assertInstanceOf(Release::class, $release);
207-
$this->assertEquals('v2.6.10', $release->getVersion());
208-
$this->assertEquals('v2.6.10.zip', $release->getRelease());
207+
$this->assertEquals('2.6.1', $release->getVersion());
208+
$this->assertEquals('2.6.1.zip', $release->getRelease());
209209
}
210210

211211
/** @test */
@@ -220,11 +220,11 @@ public function it_can_fetch_github_tag_releases_specific_version(): void
220220
/** @var GithubTagType $github */
221221
$github = (resolve(GithubRepositoryType::class))->create();
222222

223-
$release = $github->fetch('v2.6.7');
223+
$release = $github->fetch('2.6.0');
224224

225225
$this->assertInstanceOf(Release::class, $release);
226-
$this->assertEquals('v2.6.7', $release->getVersion());
227-
$this->assertEquals('v2.6.7.zip', $release->getRelease());
226+
$this->assertEquals('2.6.0', $release->getVersion());
227+
$this->assertEquals('2.6.0.zip', $release->getRelease());
228228
}
229229

230230
/** @test */
@@ -242,8 +242,8 @@ public function it_can_fetch_github_tag_releases_and_takes_latest_if_version_not
242242
$release = $github->fetch('v3.22.1');
243243

244244
$this->assertInstanceOf(Release::class, $release);
245-
$this->assertEquals('v2.6.10', $release->getVersion());
246-
$this->assertEquals('v2.6.10.zip', $release->getRelease());
245+
$this->assertEquals('2.6.1', $release->getVersion());
246+
$this->assertEquals('2.6.1.zip', $release->getRelease());
247247
}
248248

249249
/** @test */

tests/UpdaterManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function it_can_get_new_version_through_updater_manager_available_from_ty
7272
$repository = $manager->source('');
7373
$repository->deleteVersionFile();
7474

75-
$this->assertFalse($repository->isNewVersionAvailable('v2.7'));
76-
$this->assertTrue($repository->isNewVersionAvailable('v1.1'));
75+
$this->assertFalse($repository->isNewVersionAvailable('2.7'));
76+
$this->assertTrue($repository->isNewVersionAvailable('1.1'));
7777
}
7878

7979
/** @test */

0 commit comments

Comments
 (0)