Skip to content

Commit abfa5a2

Browse files
replace deprecated getContent with getContents
1 parent 6d5fff1 commit abfa5a2

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

lib/IssueBodyChecker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function fromBase64 (content) {
44

55
async function getIssueTemplateBody (context, path) {
66
try {
7-
const singleTemplate = await context.github.repos.getContent(
7+
const singleTemplate = await context.github.repos.getContents(
88
context.repo({ path })
99
)
1010

@@ -16,7 +16,7 @@ async function getIssueTemplateBody (context, path) {
1616

1717
async function getIssueTemplatePaths (context) {
1818
try {
19-
const templatesDirectory = await context.github.repos.getContent(
19+
const templatesDirectory = await context.github.repos.getContents(
2020
context.repo({ path: '.github/ISSUE_TEMPLATE/' })
2121
)
2222
return templatesDirectory.data.map(f => f.path)

lib/PullRequestBodyChecker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
async function getPullRequestTemplate (context) {
2-
const result = await context.github.repos.getContent({
2+
const result = await context.github.repos.getContents({
33
owner: context.payload.repository.owner.login,
44
repo: context.payload.repository.name,
55
path: '.github/PULL_REQUEST_TEMPLATE.md'

test/index.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('Request info', () => {
2020

2121
github = {
2222
repos: {
23-
getContent: expect.createSpy().andReturn(Promise.resolve({
23+
getContents: expect.createSpy().andReturn(Promise.resolve({
2424
data: {
2525
content: Buffer.from(`requestInfoLabelToAdd: needs-more-info\nrequestInfoDefaultTitles:\n - readme.md\nrequestInfoReplyComment: >\n Reply comment`).toString('base64')
2626
}
@@ -39,7 +39,7 @@ describe('Request info', () => {
3939
it('there wasn\'t enough info provided in an issue', async () => {
4040
await app.receive(issueSuccessEvent)
4141

42-
expect(github.repos.getContent).toHaveBeenCalledWith({
42+
expect(github.repos.getContents).toHaveBeenCalledWith({
4343
owner: 'hiimbex',
4444
repo: 'testing-things',
4545
path: '.github/config.yml'
@@ -54,7 +54,7 @@ describe('Request info', () => {
5454
it('there wasn\'t enough info provided in a pull request', async () => {
5555
await app.receive(prSuccessEvent)
5656

57-
expect(github.repos.getContent).toHaveBeenCalledWith({
57+
expect(github.repos.getContents).toHaveBeenCalledWith({
5858
owner: 'hiimbex',
5959
repo: 'testing-things',
6060
path: '.github/config.yml'
@@ -69,7 +69,7 @@ describe('Request info', () => {
6969
it('there was a body in issue', async () => {
7070
await app.receive(issueFailEvent)
7171

72-
expect(github.repos.getContent).toHaveBeenCalledWith({
72+
expect(github.repos.getContents).toHaveBeenCalledWith({
7373
owner: 'hiimbex',
7474
repo: 'testing-things',
7575
path: '.github/config.yml'
@@ -83,7 +83,7 @@ describe('Request info', () => {
8383

8484
describe('Request info disabled for issues', () => {
8585
beforeEach(() => {
86-
github.repos.getContent.andReturn(Promise.resolve({
86+
github.repos.getContents.andReturn(Promise.resolve({
8787
data: {
8888
content: Buffer.from(`requestInfoLabelToAdd: needs-more-info\nrequestInfoDefaultTitles:\n - readme.md\nrequestInfoReplyComment: >\n Reply comment\nrequestInfoOn:\n issue: false\n pullRequest: true\n`).toString('base64')
8989
}
@@ -94,7 +94,7 @@ describe('Request info', () => {
9494
it("'issue' type is disabled even if there wasn't enough info provided", async () => {
9595
await app.receive(issueSuccessEvent)
9696

97-
expect(github.repos.getContent).toHaveBeenCalledWith({
97+
expect(github.repos.getContents).toHaveBeenCalledWith({
9898
owner: 'hiimbex',
9999
repo: 'testing-things',
100100
path: '.github/config.yml'
@@ -109,7 +109,7 @@ describe('Request info', () => {
109109
it('there was a body in issue', async () => {
110110
await app.receive(issueFailEvent)
111111

112-
expect(github.repos.getContent).toHaveBeenCalledWith({
112+
expect(github.repos.getContents).toHaveBeenCalledWith({
113113
owner: 'hiimbex',
114114
repo: 'testing-things',
115115
path: '.github/config.yml'
@@ -124,7 +124,7 @@ describe('Request info', () => {
124124
it('there wasn\'t enough info provided in a pull request', async () => {
125125
await app.receive(prSuccessEvent)
126126

127-
expect(github.repos.getContent).toHaveBeenCalledWith({
127+
expect(github.repos.getContents).toHaveBeenCalledWith({
128128
owner: 'hiimbex',
129129
repo: 'testing-things',
130130
path: '.github/config.yml'
@@ -138,7 +138,7 @@ describe('Request info', () => {
138138

139139
describe('Request info disabled for pull requests', () => {
140140
beforeEach(() => {
141-
github.repos.getContent.andReturn(Promise.resolve({
141+
github.repos.getContents.andReturn(Promise.resolve({
142142
data: {
143143
content: Buffer.from(`requestInfoLabelToAdd: needs-more-info\nrequestInfoDefaultTitles:\n - readme.md\nrequestInfoReplyComment: >\n Reply comment\nrequestInfoOn:\n issue: true\n pullRequest: false\n`).toString('base64')
144144
}
@@ -149,7 +149,7 @@ describe('Request info', () => {
149149
it("'pullRequest' type is disabled even if there wasn't enough info provided", async () => {
150150
await app.receive(prSuccessEvent)
151151

152-
expect(github.repos.getContent).toHaveBeenCalledWith({
152+
expect(github.repos.getContents).toHaveBeenCalledWith({
153153
owner: 'hiimbex',
154154
repo: 'testing-things',
155155
path: '.github/config.yml'
@@ -164,7 +164,7 @@ describe('Request info', () => {
164164
it('there was a body in pr', async () => {
165165
await app.receive(prFailEvent)
166166

167-
expect(github.repos.getContent).toHaveBeenCalledWith({
167+
expect(github.repos.getContents).toHaveBeenCalledWith({
168168
owner: 'hiimbex',
169169
repo: 'testing-things',
170170
path: '.github/config.yml'
@@ -179,7 +179,7 @@ describe('Request info', () => {
179179
it('there wasn\'t enough info provided (issue type still working)', async () => {
180180
await app.receive(issueSuccessEvent)
181181

182-
expect(github.repos.getContent).toHaveBeenCalledWith({
182+
expect(github.repos.getContents).toHaveBeenCalledWith({
183183
owner: 'hiimbex',
184184
repo: 'testing-things',
185185
path: '.github/config.yml'
@@ -193,7 +193,7 @@ describe('Request info', () => {
193193

194194
describe('Request info for random comment', () => {
195195
beforeEach(() => {
196-
github.repos.getContent.andReturn(Promise.resolve({
196+
github.repos.getContents.andReturn(Promise.resolve({
197197
data: {
198198
content: Buffer.from(`requestInfoReplyComment:\n - Reply comment\n - Other reply comment`).toString('base64')
199199
}
@@ -204,7 +204,7 @@ describe('Request info', () => {
204204
it('selects a random comment and posts it', async () => {
205205
await app.receive(prSuccessEvent)
206206

207-
expect(github.repos.getContent).toHaveBeenCalledWith({
207+
expect(github.repos.getContents).toHaveBeenCalledWith({
208208
owner: 'hiimbex',
209209
repo: 'testing-things',
210210
path: '.github/config.yml'
@@ -218,7 +218,7 @@ describe('Request info', () => {
218218

219219
describe('Request info for excluded user', () => {
220220
beforeEach(() => {
221-
github.repos.getContent.andReturn(Promise.resolve({
221+
github.repos.getContents.andReturn(Promise.resolve({
222222
data: {
223223
content: Buffer.from(`requestInfoUserstoExclude:\n - hiimbex\n - bexo`).toString('base64')
224224
}
@@ -229,7 +229,7 @@ describe('Request info', () => {
229229
it('selects a random comment and posts it', async () => {
230230
await app.receive(prSuccessEvent)
231231

232-
expect(github.repos.getContent).toHaveBeenCalledWith({
232+
expect(github.repos.getContents).toHaveBeenCalledWith({
233233
owner: 'hiimbex',
234234
repo: 'testing-things',
235235
path: '.github/config.yml'
@@ -244,7 +244,7 @@ describe('Request info', () => {
244244
describe('Request info based on Pull Request template', () => {
245245
describe('If the setting is set to true', () => {
246246
beforeEach(() => {
247-
github.repos.getContent.andCall(({path}) => {
247+
github.repos.getContents.andCall(({path}) => {
248248
if (path === '.github/PULL_REQUEST_TEMPLATE.md') {
249249
return Promise.resolve({
250250
data: {
@@ -264,7 +264,7 @@ describe('Request info', () => {
264264
it('Posts a comment when PR body is equal to template', async () => {
265265
await app.receive(prTemplateBodyEvent)
266266

267-
expect(github.repos.getContent).toHaveBeenCalledWith({
267+
expect(github.repos.getContents).toHaveBeenCalledWith({
268268
owner: 'hiimbex',
269269
repo: 'testing-things',
270270
path: '.github/config.yml'
@@ -276,7 +276,7 @@ describe('Request info', () => {
276276
it('Does not post a comment when PR body is different from template', async () => {
277277
await app.receive(prFailEvent)
278278

279-
expect(github.repos.getContent).toHaveBeenCalledWith({
279+
expect(github.repos.getContents).toHaveBeenCalledWith({
280280
owner: 'hiimbex',
281281
repo: 'testing-things',
282282
path: '.github/config.yml'
@@ -288,7 +288,7 @@ describe('Request info', () => {
288288

289289
describe('If the setting is set to false', () => {
290290
beforeEach(() => {
291-
github.repos.getContent.andCall(({path}) => {
291+
github.repos.getContents.andCall(({path}) => {
292292
if (path === '.github/PULL_REQUEST_TEMPLATE.md') {
293293
return Promise.resolve({
294294
data: {
@@ -308,7 +308,7 @@ describe('Request info', () => {
308308
it('Does not post a comment when PR body is equal to template', async () => {
309309
await app.receive(prTemplateBodyEvent)
310310

311-
expect(github.repos.getContent).toHaveBeenCalledWith({
311+
expect(github.repos.getContents).toHaveBeenCalledWith({
312312
owner: 'hiimbex',
313313
repo: 'testing-things',
314314
path: '.github/config.yml'
@@ -320,7 +320,7 @@ describe('Request info', () => {
320320
it('Does not post a comment when PR body is different from template', async () => {
321321
await app.receive(prFailEvent)
322322

323-
expect(github.repos.getContent).toHaveBeenCalledWith({
323+
expect(github.repos.getContents).toHaveBeenCalledWith({
324324
owner: 'hiimbex',
325325
repo: 'testing-things',
326326
path: '.github/config.yml'
@@ -334,7 +334,7 @@ describe('Request info', () => {
334334
describe('Request info based on issue template', () => {
335335
describe('If the setting is set to false', () => {
336336
beforeEach(() => {
337-
github.repos.getContent.andCall(({path}) => {
337+
github.repos.getContents.andCall(({path}) => {
338338
return Promise.resolve({
339339
data: {
340340
content: Buffer.from(`checkIssueTemplate: false`).toString('base64')
@@ -346,7 +346,7 @@ describe('Request info', () => {
346346
it('posts a message when issue body is empty', async () => {
347347
await app.receive(issueSuccessEvent)
348348

349-
expect(github.repos.getContent).toHaveBeenCalledWith({
349+
expect(github.repos.getContents).toHaveBeenCalledWith({
350350
owner: 'hiimbex',
351351
repo: 'testing-things',
352352
path: '.github/config.yml'
@@ -358,7 +358,7 @@ describe('Request info', () => {
358358
it('does not post a message when PR body has text', async () => {
359359
await app.receive(issueFailEvent)
360360

361-
expect(github.repos.getContent).toHaveBeenCalledWith({
361+
expect(github.repos.getContents).toHaveBeenCalledWith({
362362
owner: 'hiimbex',
363363
repo: 'testing-things',
364364
path: '.github/config.yml'
@@ -371,7 +371,7 @@ describe('Request info', () => {
371371
describe('If the setting is set to true', () => {
372372
describe('And the user has no issue template defined', () => {
373373
beforeEach(() => {
374-
github.repos.getContent.andCall(({path}) => {
374+
github.repos.getContents.andCall(({path}) => {
375375
if (path === '.github/ISSUE_TEMPLATE.md') {
376376
return Promise.reject(new Error('404'))
377377
}
@@ -387,7 +387,7 @@ describe('Request info', () => {
387387
it('posts a message when issue body is empty', async () => {
388388
await app.receive(issueSuccessEvent)
389389

390-
expect(github.repos.getContent).toHaveBeenCalledWith({
390+
expect(github.repos.getContents).toHaveBeenCalledWith({
391391
owner: 'hiimbex',
392392
repo: 'testing-things',
393393
path: '.github/config.yml'
@@ -399,7 +399,7 @@ describe('Request info', () => {
399399
it('does not post a message when PR body has text', async () => {
400400
await app.receive(issueFailEvent)
401401

402-
expect(github.repos.getContent).toHaveBeenCalledWith({
402+
expect(github.repos.getContents).toHaveBeenCalledWith({
403403
owner: 'hiimbex',
404404
repo: 'testing-things',
405405
path: '.github/config.yml'
@@ -411,7 +411,7 @@ describe('Request info', () => {
411411

412412
describe('And the user has one template defined', () => {
413413
beforeEach(() => {
414-
github.repos.getContent.andCall(({path}) => {
414+
github.repos.getContents.andCall(({path}) => {
415415
if (path === '.github/ISSUE_TEMPLATE.md') {
416416
return Promise.resolve({
417417
data: {
@@ -431,7 +431,7 @@ describe('Request info', () => {
431431
it('posts a message when issue body is empty', async () => {
432432
await app.receive(issueSuccessEvent)
433433

434-
expect(github.repos.getContent).toHaveBeenCalledWith({
434+
expect(github.repos.getContents).toHaveBeenCalledWith({
435435
owner: 'hiimbex',
436436
repo: 'testing-things',
437437
path: '.github/config.yml'
@@ -443,7 +443,7 @@ describe('Request info', () => {
443443
it('posts a message when issue body matches template', async () => {
444444
await app.receive(issueTemplateBodyEvent)
445445

446-
expect(github.repos.getContent).toHaveBeenCalledWith({
446+
expect(github.repos.getContents).toHaveBeenCalledWith({
447447
owner: 'hiimbex',
448448
repo: 'testing-things',
449449
path: '.github/config.yml'
@@ -455,7 +455,7 @@ describe('Request info', () => {
455455
it('does not post a message when issue body is different to template', async () => {
456456
await app.receive(issueFailEvent)
457457

458-
expect(github.repos.getContent).toHaveBeenCalledWith({
458+
expect(github.repos.getContents).toHaveBeenCalledWith({
459459
owner: 'hiimbex',
460460
repo: 'testing-things',
461461
path: '.github/config.yml'
@@ -467,7 +467,7 @@ describe('Request info', () => {
467467

468468
describe('And the user has multiple templates defined', () => {
469469
beforeEach(() => {
470-
github.repos.getContent.andCall(({path}) => {
470+
github.repos.getContents.andCall(({path}) => {
471471
if (path === '.github/ISSUE_TEMPLATE.md') {
472472
return Promise.reject(new Error('404'))
473473
}
@@ -514,7 +514,7 @@ describe('Request info', () => {
514514
it('posts a message when issue body is empty', async () => {
515515
await app.receive(issueSuccessEvent)
516516

517-
expect(github.repos.getContent).toHaveBeenCalledWith({
517+
expect(github.repos.getContents).toHaveBeenCalledWith({
518518
owner: 'hiimbex',
519519
repo: 'testing-things',
520520
path: '.github/config.yml'
@@ -526,7 +526,7 @@ describe('Request info', () => {
526526
it('posts a message when issue body matches first template', async () => {
527527
await app.receive(issueFirstTemplateBodyEvent)
528528

529-
expect(github.repos.getContent).toHaveBeenCalledWith({
529+
expect(github.repos.getContents).toHaveBeenCalledWith({
530530
owner: 'hiimbex',
531531
repo: 'testing-things',
532532
path: '.github/config.yml'
@@ -538,7 +538,7 @@ describe('Request info', () => {
538538
it('posts a message when issue body matches second template', async () => {
539539
await app.receive(issueSecondTemplateBodyEvent)
540540

541-
expect(github.repos.getContent).toHaveBeenCalledWith({
541+
expect(github.repos.getContents).toHaveBeenCalledWith({
542542
owner: 'hiimbex',
543543
repo: 'testing-things',
544544
path: '.github/config.yml'
@@ -550,7 +550,7 @@ describe('Request info', () => {
550550
it('does not post a message when issue body is different to all templates', async () => {
551551
await app.receive(issueFailEvent)
552552

553-
expect(github.repos.getContent).toHaveBeenCalledWith({
553+
expect(github.repos.getContents).toHaveBeenCalledWith({
554554
owner: 'hiimbex',
555555
repo: 'testing-things',
556556
path: '.github/config.yml'

0 commit comments

Comments
 (0)