diff --git a/lib/find-sr-issues.js b/lib/find-sr-issues.js index 6670866d..d99c14a4 100644 --- a/lib/find-sr-issues.js +++ b/lib/find-sr-issues.js @@ -3,7 +3,7 @@ const ISSUE_ID = require('./definitions/sr-issue-id'); module.exports = async (github, title, owner, repo) => { const { data: {items: issues}, - } = await github.search.issues({ + } = await github.search.issuesAndPullRequests({ q: `in:title+repo:${owner}/${repo}+type:issue+state:open+${title}`, }); diff --git a/lib/get-client.js b/lib/get-client.js index efb0d316..56caa9f2 100644 --- a/lib/get-client.js +++ b/lib/get-client.js @@ -31,12 +31,15 @@ module.exports = ({githubToken, githubUrl, githubApiPathPrefix, proxy}) => { const baseUrl = githubUrl && urljoin(githubUrl, githubApiPathPrefix); const globalThrottler = new Bottleneck({minTime: GLOBAL_RATE_LIMIT}); const github = new Octokit({ + auth: `token ${githubToken}`, baseUrl, - agent: proxy - ? baseUrl && url.parse(baseUrl).protocol.replace(':', '') === 'http' - ? new HttpProxyAgent(proxy) - : new HttpsProxyAgent(proxy) - : undefined, + request: { + agent: proxy + ? baseUrl && url.parse(baseUrl).protocol.replace(':', '') === 'http' + ? new HttpProxyAgent(proxy) + : new HttpsProxyAgent(proxy) + : undefined, + }, }); github.hook.wrap('request', (request, options) => { @@ -56,7 +59,5 @@ module.exports = ({githubToken, githubUrl, githubApiPathPrefix, proxy}) => { }, RETRY_CONF); }); - github.authenticate({type: 'token', token: githubToken}); - return github; }; diff --git a/lib/success.js b/lib/success.js index f53fd48e..b976817f 100644 --- a/lib/success.js +++ b/lib/success.js @@ -45,7 +45,7 @@ module.exports = async (pluginConfig, context) => { const shas = commits.map(({hash}) => hash); const searchQueries = getSearchQueries(`repo:${owner}/${repo}+type:pr+is:merged`, shas).map( - async q => (await github.search.issues({q})).data.items + async q => (await github.search.issuesAndPullRequests({q})).data.items ); const prs = await pFilter( diff --git a/package.json b/package.json index cf674605..139f9aca 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "Gregor Martynus (https://twitter.com/gr2m)" ], "dependencies": { - "@octokit/rest": "^16.0.1", + "@octokit/rest": "^16.13.1", "@semantic-release/error": "^2.2.0", "aggregate-error": "^2.0.0", "bottleneck": "^2.0.1", diff --git a/test/get-client.test.js b/test/get-client.test.js index f5c6c82a..3e90cba9 100644 --- a/test/get-client.test.js +++ b/test/get-client.test.js @@ -100,8 +100,8 @@ test('Use the global throttler for all endpoints', async t => { const b = await github.issues.createComment(); const c = await github.repos.createRelease(); const d = await github.issues.createComment(); - const e = await github.search.issues(); - const f = await github.search.issues(); + const e = await github.search.issuesAndPullRequests(); + const f = await github.search.issuesAndPullRequests(); // `issues.createComment` should be called `rate` ms after `repos.createRelease` t.true(inRange(b - a, rate - 50, rate + 50)); @@ -109,9 +109,9 @@ test('Use the global throttler for all endpoints', async t => { t.true(inRange(c - b, rate - 50, rate + 50)); // `issues.createComment` should be called `rate` ms after `repos.createRelease` t.true(inRange(d - c, rate - 50, rate + 50)); - // `search.issues` should be called `rate` ms after `issues.createComment` + // `search.issuesAndPullRequests` should be called `rate` ms after `issues.createComment` t.true(inRange(e - d, rate - 50, rate + 50)); - // `search.issues` should be called `rate` ms after `search.issues` + // `search.issuesAndPullRequests` should be called `rate` ms after `search.issuesAndPullRequests` t.true(inRange(f - e, rate - 50, rate + 50)); }); @@ -130,8 +130,8 @@ test('Use the same throttler for endpoints in the same rate limit group', async const b = await github.issues.createComment(); const c = await github.repos.createRelease(); const d = await github.issues.createComment(); - const e = await github.search.issues(); - const f = await github.search.issues(); + const e = await github.search.issuesAndPullRequests(); + const f = await github.search.issuesAndPullRequests(); // `issues.createComment` should be called `coreRate` ms after `repos.createRelease` t.true(inRange(b - a, coreRate - 50, coreRate + 50));