Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
fix: Fix the way to remove a label
Browse files Browse the repository at this point in the history
g ps
  • Loading branch information
sotayamashita committed Nov 21, 2017
1 parent e6ae253 commit 079e43b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/handle-pull-request-change.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const getDebug = require('debug')

async function handlePullRequestChange (robot, context) {
const pullRequest = context.payload.pull_request || context.payload.review.pull_request
const number = pullRequest.number
Expand All @@ -11,10 +13,13 @@ async function handlePullRequestChange (robot, context) {
number: number
}

const debug = getDebug(`probot:pr-label:${context.payload.repository.full_name.toLowerCase()}`)

// Do nothing if title includes wip
// such as GitLab's "Work In Progress" Merge Requests
if (title.match(/^wip(?=:|)/i)) {
console.log(title)
debug(`ignoring: "${title}" matches /^wip(?=:|)/i`)
updateLabelIfNeeded(context, params, '')
return false
}

Expand All @@ -41,7 +46,7 @@ async function handlePullRequestChange (robot, context) {
}
}
}
console.log(JSON.stringify(filteredReviewRequestByUserId, 0, 2))
debug(`info: #{JSON.stringify(filteredReviewRequestByUserId, 0, 2)}`)

if (Object.keys(filteredReviewRequestByUserId).length === 0) {
// Add PR:unreviewed
Expand Down Expand Up @@ -78,8 +83,8 @@ async function updateLabelIfNeeded (context, params, label) {
if (response.data.labels[i] === label) {
shouldUpdateLabel = false
break
} else if (response.data.labels[i].match(/PR:/)) {
removeLabel(context, params, response.data.labels[i])
} else if (response.data.labels[i].name.match(/PR:/)) {
removeLabel(context, params, response.data.labels[i].name)
}
}

Expand Down

0 comments on commit 079e43b

Please sign in to comment.