Skip to content

Commit 587686a

Browse files
committed
Fix breakage with updated GitHub REST API
The REST API was changed some time ago to first suggest, and then require, the `.rest.` infix. I forgot about that when I updated the dependencies. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent e88e499 commit 587686a

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

__tests__/index.test.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ https.get = jest.fn().mockImplementation((url, callback) => {
3838
})
3939

4040
const octokit = {
41-
issues: {
42-
create: jest.fn(),
43-
listForRepo: jest.fn()
41+
rest: {
42+
issues: {
43+
create: jest.fn(),
44+
listForRepo: jest.fn()
45+
}
4446
}
4547
}
4648
getOctokit.mockImplementation(() => octokit)
@@ -51,20 +53,20 @@ test('handles feeds without any entries', async () => {
5153
await run()
5254

5355
expect(https.get).toHaveBeenCalledTimes(1)
54-
expect(octokit.issues.listForRepo).not.toHaveBeenCalled()
55-
expect(octokit.issues.create).not.toHaveBeenCalled()
56+
expect(octokit.rest.issues.listForRepo).not.toHaveBeenCalled()
57+
expect(octokit.rest.issues.create).not.toHaveBeenCalled()
5658
})
5759

5860
test('handles feed entries without titles', async () => {
5961
const date = '2021-06-19T01:01:29+12:00'
6062
mockHTTPSGet.__RETURN__ = `<feed xmlns="http://www.w3.org/2005/Atom"><entry><published>${date}</published><content type="html">TBD</content></entry></feed>`
6163
core.__INPUTS__['max-age'] = '9999d'
62-
octokit.issues.listForRepo.mockReturnValueOnce({ data: [] })
64+
octokit.rest.issues.listForRepo.mockReturnValueOnce({ data: [] })
6365
await run()
6466

6567
expect(https.get).toHaveBeenCalledTimes(1)
66-
expect(octokit.issues.listForRepo).toHaveBeenCalledTimes(1)
67-
expect(octokit.issues.create).toHaveBeenCalledWith({
68+
expect(octokit.rest.issues.listForRepo).toHaveBeenCalledTimes(1)
69+
expect(octokit.rest.issues.create).toHaveBeenCalledWith({
6870
owner: 'owner',
6971
repo: 'repo',
7072
title: new Date(date).toUTCString(),
@@ -103,10 +105,10 @@ Signed-off-by: Johannes Schindelin &amp;lt;johannes.schindelin@gmx.de&amp;gt;&lt
103105
</entry>
104106
</feed>
105107
`
106-
octokit.issues.listForRepo.mockReturnValueOnce({ data: [] })
108+
octokit.rest.issues.listForRepo.mockReturnValueOnce({ data: [] })
107109
await run()
108110

109-
expect(octokit.issues.create).toHaveBeenCalledWith({
111+
expect(octokit.rest.issues.create).toHaveBeenCalledWith({
110112
owner: 'owner',
111113
repo: 'repo',
112114
title: 'ci(release-tags): use newer versions of Actions',

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const run = async () => {
5050
// Remove old items in feed
5151
feed.items = feed.items.filter(x => x.pubDate === undefined || limitTime < new Date(x.pubDate).getTime())
5252

53-
const { data: issues } = await octokit.issues.listForRepo({
53+
const { data: issues } = await octokit.rest.issues.listForRepo({
5454
owner: context.repo.owner,
5555
repo: context.repo.repo,
5656
state: 'all',
@@ -125,7 +125,7 @@ const run = async () => {
125125
core.info(`Would create issue '${issue.title}' with content '${issue.body}'`)
126126
} else {
127127
try {
128-
const { data } = await octokit.issues.create({
128+
const { data } = await octokit.rest.issues.create({
129129
owner: context.repo.owner,
130130
repo: context.repo.repo,
131131
title: issue.title,

0 commit comments

Comments
 (0)