Skip to content

Commit

Permalink
fix: check up to 12 pages of tags (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Feb 24, 2021
1 parent aaf28d5 commit 4565a0c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export const getRelease = async (
prefix?: string
): Promise<string | undefined> => {
const client = gh.client(token, clientOptions);
// We check up to 600 of the most recent tags for a matching release,
// We check up to 1200 of the most recent tags for a matching release,
// we use a large page size to allow for monorepos with 100s of tags:
const maxPagination = 6;
const maxPagination = 12;
for (let page = 1; page < maxPagination; page++) {
const tags: [{name: string}] = await new Promise((resolve, reject) => {
client.get(
Expand Down
14 changes: 13 additions & 1 deletion test/lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,19 @@ describe('github', () => {
.get('/repos/bcoe/test/tags?per_page=100&page=4')
.reply(200, [{name: 'v1.0.5'}])
.get('/repos/bcoe/test/tags?per_page=100&page=5')
.reply(200, [{name: 'v1.0.6'}]);
.reply(200, [{name: 'v1.0.6'}])
.get('/repos/bcoe/test/tags?per_page=100&page=6')
.reply(200, [{name: 'v1.0.7'}])
.get('/repos/bcoe/test/tags?per_page=100&page=7')
.reply(200, [{name: 'v1.0.8'}])
.get('/repos/bcoe/test/tags?per_page=100&page=8')
.reply(200, [{name: 'v1.0.9'}])
.get('/repos/bcoe/test/tags?per_page=100&page=9')
.reply(200, [{name: 'v1.0.10'}])
.get('/repos/bcoe/test/tags?per_page=100&page=10')
.reply(200, [{name: 'v1.0.10'}])
.get('/repos/bcoe/test/tags?per_page=100&page=11')
.reply(200, [{name: 'v1.0.10'}]);

expect(
await github.getRelease('bcoe/test', 'abc123', 'v1.0.2', 'foo')
Expand Down
12 changes: 12 additions & 0 deletions test/lib/write-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ describe('writePackage', () => {
.get('/repos/foo/bar/tags?per_page=100&page=4')
.reply(200, [{name: 'v0.1.0'}])
.get('/repos/foo/bar/tags?per_page=100&page=5')
.reply(200, [{name: 'v0.1.0'}])
.get('/repos/foo/bar/tags?per_page=100&page=6')
.reply(200, [{name: 'v0.1.0'}])
.get('/repos/foo/bar/tags?per_page=100&page=7')
.reply(200, [{name: 'v0.1.0'}])
.get('/repos/foo/bar/tags?per_page=100&page=8')
.reply(200, [{name: 'v0.1.0'}])
.get('/repos/foo/bar/tags?per_page=100&page=9')
.reply(200, [{name: 'v0.1.0'}])
.get('/repos/foo/bar/tags?per_page=100&page=10')
.reply(200, [{name: 'v0.1.0'}])
.get('/repos/foo/bar/tags?per_page=100&page=11')
.reply(200, [{name: 'v0.1.0'}]);

const ret = await writePackage('@soldair/foo', req, res);
Expand Down

0 comments on commit 4565a0c

Please sign in to comment.