Skip to content

Commit

Permalink
Merge branch 'master' into website-url-query-param
Browse files Browse the repository at this point in the history
  • Loading branch information
repo-ranger[bot] authored Sep 16, 2019
2 parents c6c12b7 + 76b2e26 commit 6cf9f64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/github/github-downloads.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ module.exports = class GithubDownloads extends GithubAuthV3Service {
options: { qs: { per_page: 1 } },
errorMessages: errorMessagesFor('repo not found'),
})
// Note that the API will return an empty array if there are no releases
// https://github.com/badges/shields/issues/3786
if (!latestReleaseIncludingPrereleases) {
throw new NotFound({ prettyMessage: 'no releases' })
}
releases = [latestReleaseIncludingPrereleases]
} else if (tag) {
const wantedRelease = await this._requestJson({
Expand Down
5 changes: 5 additions & 0 deletions services/github/github-downloads.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ t.create('downloads-pre for latest release')
.get('/downloads-pre/photonstorm/phaser/latest/total.json')
.expectBadge({ label: 'downloads@latest', message: isMetric })

// https://github.com/badges/shields/issues/3786
t.create('downloads-pre for latest release (no-releases)')
.get('/downloads-pre/badges/shields/latest/total.json')
.expectBadge({ label: 'downloads', message: 'no releases' })

t.create('downloads for release without slash')
.get('/downloads/atom/atom/v0.190.0/total.json')
.expectBadge({ label: '[email protected]', message: isMetric })
Expand Down

0 comments on commit 6cf9f64

Please sign in to comment.