diff --git a/src/client.ts b/src/client.ts index d5933ef..c0e4e89 100644 --- a/src/client.ts +++ b/src/client.ts @@ -90,7 +90,7 @@ type Commit = components['schemas']['commit']; // https://docs.github.com/en/rest/commits/commits#get-a-commit export async function getCommit(context: any, sha: string): Promise { const request = context.repo({ - sha, + ref: sha, }); const { data: commit } = await context.octokit.rest.repos.getCommit(request); return commit; diff --git a/tests/handlers/deployment-protection-rule.test.ts b/tests/handlers/deployment-protection-rule.test.ts index 1c0bc6d..1833dbc 100644 --- a/tests/handlers/deployment-protection-rule.test.ts +++ b/tests/handlers/deployment-protection-rule.test.ts @@ -60,8 +60,7 @@ describe('Deployment Protection Rule Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 5 }, committer: { id: 123 } }) .post( '/repos/test-org/test-repo/actions/runs/1234/deployment_protection_rule', @@ -114,8 +113,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, []) @@ -142,8 +140,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, []) @@ -168,8 +165,7 @@ describe('Deployment Protection Rule Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 5 }, committer: { id: 123 } }) .post( '/repos/test-org/test-repo/actions/runs/1234/deployment_protection_rule', @@ -190,8 +186,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, [ @@ -223,8 +218,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, [ @@ -256,8 +250,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 456 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, [ @@ -291,8 +284,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 456 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, [ @@ -326,8 +318,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, [ @@ -361,8 +352,7 @@ describe('Deployment Protection Rule Handler', () => { .reply(200, { token: 'test', permissions: { issues: 'write' } }) .get('/app') .reply(200, { id: 456 }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/pulls/123/reviews') .reply(200, []) diff --git a/tests/handlers/pull-request-review.test.ts b/tests/handlers/pull-request-review.test.ts index 5d4b8f6..9a9c859 100644 --- a/tests/handlers/pull-request-review.test.ts +++ b/tests/handlers/pull-request-review.test.ts @@ -60,8 +60,7 @@ describe('Pull Request Review Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/actions/runs') .query(true) @@ -153,8 +152,7 @@ describe('Pull Request Review Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 456 } }); await probot.receive({ @@ -180,8 +178,7 @@ describe('Pull Request Review Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 456 }, committer: { id: 123 } }); await probot.receive({ @@ -196,8 +193,7 @@ describe('Pull Request Review Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/actions/runs') .query(true) @@ -215,8 +211,7 @@ describe('Pull Request Review Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/actions/runs') .query(true) @@ -236,8 +231,7 @@ describe('Pull Request Review Handler', () => { const mock = nock('https://api.github.com') .post('/app/installations/12345678/access_tokens') .reply(200, { token: 'test', permissions: { issues: 'write' } }) - .get('/repos/test-org/test-repo/commits') - .query(true) + .get('/repos/test-org/test-repo/commits/test-sha') .reply(200, { author: { id: 123 }, committer: { id: 123 } }) .get('/repos/test-org/test-repo/actions/runs') .query(true)