Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for empty label #10

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions src/pull-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,61 @@ module.exports = async (context) => {

if (state === 'open') {
// Remove pr-rejected label if it exists.
try {
if (config.rejected) {
try {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.removeLabel(context.repo({ number: ele, name: config.rejected })))
})
await Promise.all(promises)
} catch (e) { }
}
// Add label to the issues.
if (config.opened) {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.removeLabel(context.repo({ number: ele, name: config.rejected })))
promises.push(github.issues.addLabels(context.repo({ number: ele, labels: [config.opened] })))
})
await Promise.all(promises)
} catch (e) { }

// Add label to the issues.
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.addLabels(context.repo({ number: ele, labels: [config.opened] })))
})
await Promise.all(promises)
}
} else if (state === 'closed') {
// Remove pr-open label if it exists.
try {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.removeLabel(context.repo({ number: ele, name: config.opened })))
})
await Promise.all(promises)
} catch (e) { }

if (merged) {
// Remove pr-rejected label if it exists.
if (config.opened) {
try {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.removeLabel(context.repo({ number: ele, name: config.rejected })))
promises.push(github.issues.removeLabel(context.repo({ number: ele, name: config.opened })))
})
await Promise.all(promises)
} catch (e) { }
}
if (merged) {
// Remove pr-rejected label if it exists.
if (config.rejected) {
try {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.removeLabel(context.repo({ number: ele, name: config.rejected })))
})
await Promise.all(promises)
} catch (e) { }
}
// Add pr-merged label to issues
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.addLabels(context.repo({ number: ele, labels: [config.merged] })))
})
if (config.merged) {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.addLabels(context.repo({ number: ele, labels: [config.merged] })))
})
}
await Promise.all(promises)
} else {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.addLabels(context.repo({ number: ele, labels: [config.rejected] })))
})
await Promise.all(promises)
if (config.rejected) {
let promises = []
issueNum.forEach(ele => {
promises.push(github.issues.addLabels(context.repo({ number: ele, labels: [config.rejected] })))
})
await Promise.all(promises)
}
}
}
}
Expand Down