Skip to content

Commit

Permalink
Pagination starts at page 1, and filter out jbrowse/web tags (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin authored Nov 10, 2020
1 parent dd78420 commit c96b026
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
13 changes: 6 additions & 7 deletions products/jbrowse-cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,9 @@ export default abstract class JBrowseCommand extends Command {

async getLatest() {
for await (const versions of this.fetchVersions()) {
const jb2webreleases = versions.filter(release =>
release.tag_name.startsWith('@jbrowse/web'),
)

// if a release was just uploaded, or an erroneous build was made
// then it might have no build asset
const nonprereleases = jb2webreleases
const nonprereleases = versions
.filter(release => release.prerelease === false)
.filter(release => release.assets && release.assets.length > 0)

Expand All @@ -216,7 +212,7 @@ export default abstract class JBrowseCommand extends Command {
}

async *fetchVersions() {
let page = 0
let page = 1
let result

do {
Expand All @@ -227,7 +223,10 @@ export default abstract class JBrowseCommand extends Command {
if (response.ok) {
// eslint-disable-next-line no-await-in-loop
result = await response.json()
yield result as GithubRelease[]

yield result.filter(release =>
release.tag_name.startsWith('@jbrowse/web'),
)
page++
} else {
throw new Error(`${result.statusText}`)
Expand Down
6 changes: 3 additions & 3 deletions products/jbrowse-cli/src/commands/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ function mockTagSuccess(gitHubApi: Scope) {

function mockReleases(gitHubApi: Scope) {
return gitHubApi
.get('/repos/GMOD/jbrowse-components/releases?page=0')
.get('/repos/GMOD/jbrowse-components/releases?page=1')
.reply(200, releaseArray)
}

function mockReleasesListVersions(gitHubApi: Scope) {
return gitHubApi
.get('/repos/GMOD/jbrowse-components/releases?page=0')
.reply(200, releaseArray)
.get('/repos/GMOD/jbrowse-components/releases?page=1')
.reply(200, releaseArray)
.get('/repos/GMOD/jbrowse-components/releases?page=2')
.reply(200, [])
}

Expand Down
2 changes: 1 addition & 1 deletion products/jbrowse-cli/src/commands/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function mockTagSuccess(gitHubApi: Scope) {

function mockReleases(gitHubApi: Scope) {
return gitHubApi
.get('/repos/GMOD/jbrowse-components/releases?page=0')
.get('/repos/GMOD/jbrowse-components/releases?page=1')
.reply(200, releaseArray)
}

Expand Down

0 comments on commit c96b026

Please sign in to comment.