Skip to content

Commit 34d1951

Browse files
committed
⬆️ Update code for octokit.js api updates
1 parent f1b34db commit 34d1951

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

‎lib/pull.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ module.exports = class Pull {
139139
const pr = await this.github.pulls.get({
140140
owner: this.config.owner,
141141
repo: this.config.repo,
142-
pr_number: res.data[i].number
142+
pull_number: res.data[i].number
143143
})
144144
if (
145145
pr.data &&
@@ -186,7 +186,7 @@ module.exports = class Pull {
186186
const pr = await this.github.pulls.get({
187187
owner: this.config.owner,
188188
repo: this.config.repo,
189-
pr_number: createdPR.data.number
189+
pull_number: createdPR.data.number
190190
})
191191
return pr.data
192192
} catch (e) {
@@ -202,7 +202,7 @@ module.exports = class Pull {
202202
const createdPR = await this.github.pulls.get({
203203
owner: this.config.owner,
204204
repo: this.config.repo,
205-
pr_number: prNumber
205+
pull_number: prNumber
206206
})
207207
this.logger.debug(`[${this.config.repoPath}]#${prNumber} Mergeability is ${createdPR.data.mergeable_state}`)
208208
// Retry if mergeable is null
@@ -223,7 +223,7 @@ module.exports = class Pull {
223223
return this.github.pulls.createReviewRequest({
224224
owner: this.config.owner,
225225
repo: this.config.repo,
226-
pr_number: prNumber,
226+
pull_number: prNumber,
227227
reviewers
228228
})
229229
}
@@ -234,7 +234,7 @@ module.exports = class Pull {
234234
owner: this.config.owner,
235235
repo: this.config.repo,
236236
merge_method,
237-
pr_number: prNumber
237+
pull_number: prNumber
238238
})
239239
}
240240

‎test/pull.test.js‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ describe('pull - routineCheck', () => {
175175
test('yes diff, already has PR', async () => {
176176
github.repos.compareCommits.mockResolvedValue({ data: { total_commits: 1 } })
177177
github.issues.listForRepo.mockResolvedValue({ data: [ { number: 13 }, { number: 12 }, { number: 14 } ] })
178-
github.pulls.get.mockImplementation(({ pr_number: number }) => {
178+
github.pulls.get.mockImplementation(({ pull_number: number }) => {
179179
switch (number) {
180180
case 12:
181181
return { data: {
@@ -221,24 +221,24 @@ describe('pull - routineCheck', () => {
221221
owner: 'wei', repo: 'fork', base: 'master', head: 'upstream:master'
222222
})
223223
expect(github.issues.listForRepo).toHaveBeenCalled()
224-
expect(github.pulls.get).nthCalledWith(1, { owner: 'wei', repo: 'fork', pr_number: 13 })
225-
expect(github.pulls.get).nthCalledWith(2, { owner: 'wei', repo: 'fork', pr_number: 12 })
224+
expect(github.pulls.get).nthCalledWith(1, { owner: 'wei', repo: 'fork', pull_number: 13 })
225+
expect(github.pulls.get).nthCalledWith(2, { owner: 'wei', repo: 'fork', pull_number: 12 })
226226
expect(github.pulls.merge).not.toHaveBeenCalledWith()
227227

228228
expect(github.repos.compareCommits).nthCalledWith(2, {
229229
owner: 'wei', repo: 'fork', base: 'feature/new-1', head: 'upstream:dev'
230230
})
231231
expect(github.issues.listForRepo).toHaveBeenCalled()
232-
expect(github.pulls.get).nthCalledWith(3, { owner: 'wei', repo: 'fork', pr_number: 13 })
233-
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 13, merge_method: 'rebase' })
232+
expect(github.pulls.get).nthCalledWith(3, { owner: 'wei', repo: 'fork', pull_number: 13 })
233+
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 13, merge_method: 'rebase' })
234234

235235
expect(github.repos.compareCommits).nthCalledWith(3, {
236236
owner: 'wei', repo: 'fork', base: 'hotfix/bug-1', head: 'upstream:dev'
237237
})
238238
expect(github.issues.listForRepo).toHaveBeenCalled()
239-
expect(github.pulls.get).nthCalledWith(4, { owner: 'wei', repo: 'fork', pr_number: 13 })
240-
expect(github.pulls.get).nthCalledWith(5, { owner: 'wei', repo: 'fork', pr_number: 12 })
241-
expect(github.pulls.get).nthCalledWith(6, { owner: 'wei', repo: 'fork', pr_number: 14 })
239+
expect(github.pulls.get).nthCalledWith(4, { owner: 'wei', repo: 'fork', pull_number: 13 })
240+
expect(github.pulls.get).nthCalledWith(5, { owner: 'wei', repo: 'fork', pull_number: 12 })
241+
expect(github.pulls.get).nthCalledWith(6, { owner: 'wei', repo: 'fork', pull_number: 14 })
242242
expect(github.git.updateRef).toHaveBeenCalledWith(
243243
{ owner: 'wei', repo: 'fork', ref: `heads/hotfix/bug-1`, sha: 'sha1-placeholder-14', force: true }
244244
)
@@ -292,7 +292,7 @@ describe('pull - routineCheck', () => {
292292
})
293293
expect(github.pulls.createReviewRequest).toHaveBeenCalledTimes(1)
294294
expect(github.pulls.createReviewRequest).nthCalledWith(1, {
295-
owner: 'wei', repo: 'fork', pr_number: 12, reviewers: ['jerry']
295+
owner: 'wei', repo: 'fork', pull_number: 12, reviewers: ['jerry']
296296
})
297297
})
298298
})
@@ -334,8 +334,8 @@ describe('pull - checkAutoMerge', () => {
334334
mergeable_state: 'unknown'
335335
})
336336
expect(github.pulls.get).toHaveBeenCalledTimes(2)
337-
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 12 })
338-
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 12, merge_method: 'merge' })
337+
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 12 })
338+
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 12, merge_method: 'merge' })
339339
expect(github.git.updateRef).not.toHaveBeenCalled()
340340

341341
github.pulls.get = jest.fn()
@@ -375,7 +375,7 @@ describe('pull - checkAutoMerge', () => {
375375
mergeable_state: 'unknown'
376376
}, { isMergeableMaxRetries: 1 })
377377
expect(github.pulls.get).toHaveBeenCalledTimes(1)
378-
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 12 })
378+
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 12 })
379379
expect(github.git.updateRef).not.toHaveBeenCalled()
380380
})
381381

@@ -396,7 +396,7 @@ describe('pull - checkAutoMerge', () => {
396396
mergeable_state: 'unknown'
397397
}, { isMergeableMaxRetries: 2 })
398398
expect(github.pulls.get).toHaveBeenCalledTimes(2)
399-
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 12 })
399+
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 12 })
400400
expect(github.git.updateRef).not.toHaveBeenCalled()
401401
})
402402

@@ -437,8 +437,8 @@ describe('pull - checkAutoMerge', () => {
437437
mergeable_state: 'unknown'
438438
})
439439
expect(github.pulls.get).toHaveBeenCalledTimes(1)
440-
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16 })
441-
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16, merge_method: 'merge' })
440+
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16 })
441+
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16, merge_method: 'merge' })
442442
expect(github.git.updateRef).not.toHaveBeenCalled()
443443
})
444444

@@ -458,8 +458,8 @@ describe('pull - checkAutoMerge', () => {
458458
mergeable_state: 'unknown'
459459
})
460460
expect(github.pulls.get).toHaveBeenCalledTimes(1)
461-
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16 })
462-
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16, merge_method: 'squash' })
461+
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16 })
462+
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16, merge_method: 'squash' })
463463
expect(github.git.updateRef).not.toHaveBeenCalled()
464464
})
465465

@@ -479,8 +479,8 @@ describe('pull - checkAutoMerge', () => {
479479
mergeable_state: 'unknown'
480480
})
481481
expect(github.pulls.get).toHaveBeenCalledTimes(1)
482-
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16 })
483-
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16, merge_method: 'rebase' })
482+
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16 })
483+
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16, merge_method: 'rebase' })
484484
expect(github.git.updateRef).not.toHaveBeenCalled()
485485
})
486486

@@ -500,8 +500,8 @@ describe('pull - checkAutoMerge', () => {
500500
mergeable_state: 'unknown'
501501
})
502502
expect(github.pulls.get).toHaveBeenCalledTimes(1)
503-
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16 })
504-
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pr_number: 16, merge_method: 'merge' })
503+
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16 })
504+
expect(github.pulls.merge).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16, merge_method: 'merge' })
505505
expect(github.git.updateRef).not.toHaveBeenCalled()
506506
})
507507
})

0 commit comments

Comments
 (0)