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

request-info bot works after label is added. #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
*.pem
.DS_Store
package-lock.json
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const defaultConfig = require('./lib/defaultConfig')
const PullRequestBodyChecker = require('./lib/PullRequestBodyChecker')

module.exports = robot => {
robot.on(['pull_request.opened', 'issues.opened'], receive)
robot.on(['pull_request.opened', 'issues.opened', 'issues.labeled', 'pull_request.labeled'], receive)
async function receive (context) {
let title
let body
Expand Down Expand Up @@ -45,8 +45,14 @@ module.exports = robot => {
}
}
if ((!body || badTitle || badBody) && notExcludedUser) {
const comment = getComment(config.requestInfoReplyComment, defaultConfig.requestInfoReplyComment)
context.github.issues.createComment(context.issue({body: comment}))
const label = await context.github.issues.getIssueLabels(context.issue())
const requestLabel = label.data.find(label => {
return label.name === 'request-info'
})
if (requestLabel) {
const comment = getComment(config.requestInfoReplyComment, defaultConfig.requestInfoReplyComment)
context.github.issues.createComment(context.issue({body: comment}))
}

if (config.requestInfoLabelToAdd) {
// Add label if there is one listed in the yaml file
Expand Down
7 changes: 6 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ describe('Request info', () => {
},
issues: {
createComment: expect.createSpy(),
addLabels: expect.createSpy()
addLabels: expect.createSpy(),
getIssueLabels: expect.createSpy().andReturn(Promise.resolve({
data: [{
name: 'request-info'
}]
}))
}
}
robot.auth = () => Promise.resolve(github)
Expand Down