Skip to content

Commit

Permalink
Pr cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv committed Jun 9, 2019
1 parent 7f63ea4 commit 5718049
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module.exports = app => {
comment.minusOne(context, payload.comment.id)
return
}
const isMerged = await pr.isMerged(context, payload.issue.number)
const isClosed = await pr.isClosed(context, payload.issue.number)
const isMerged = await pr.isMerged(context)
const isClosed = await pr.isClosed(context)
if (isMerged || isClosed) {
// should not be merged
logger.debug('PR is already merged or closed just carry on')
Expand Down
11 changes: 5 additions & 6 deletions lib/pr.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
module.exports = {
isMerged: async function(context, id) {
const params = context.repo({ pull_number: id })
const pr = await context.github.pullRequests.get(params)
const pr = await this.getPR(context)
return pr.data.merged === true
},

isClosed: async function(context, id) {
const params = context.repo({ pull_number: id })
const pr = await context.github.pullRequests.get(params)
isClosed: async function(context) {
const pr = await this.getPR(context)
return pr.data.state === 'closed'
},

Expand All @@ -17,6 +15,7 @@ module.exports = {
},

getPR: async function(context) {
return context.github.pullRequests.get(context.issue())
const params = context.repo({ pull_number: context.payload.issue.number })
return context.github.pullRequests.get(params)
}
}

0 comments on commit 5718049

Please sign in to comment.