Merge pull request #1984 from kounoike/pr-call-webhook-when-close-by-comment

call issue closed webhook when pushed commit contains keywords
This commit is contained in:
Naoki Takezoe
2018-04-29 09:36:59 +09:00
committed by GitHub
2 changed files with 11 additions and 4 deletions

View File

@@ -700,11 +700,12 @@ trait IssuesService {
def closeIssuesFromMessage(message: String, userName: String, owner: String, repository: String)(
implicit s: Session
): Unit = {
extractCloseId(message).foreach { issueId =>
for (issue <- getIssue(owner, repository, issueId) if !issue.closed) {
): Seq[Int] = {
extractCloseId(message).flatMap { issueId =>
for (issue <- getIssue(owner, repository, issueId) if !issue.closed) yield {
createComment(owner, repository, userName, issue.issueId, "Close", "close")
updateClosed(owner, repository, issue.issueId, true)
issue.issueId
}
}
}

View File

@@ -296,7 +296,13 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
createIssueComment(owner, repository, commit)
// close issues
if (refName(1) == "heads" && branchName == defaultBranch && command.getType == ReceiveCommand.Type.UPDATE) {
closeIssuesFromMessage(commit.fullMessage, pusher, owner, repository)
getAccountByUserName(pusher).map { pusherAccount =>
closeIssuesFromMessage(commit.fullMessage, pusher, owner, repository).foreach { issueId =>
getIssue(owner, repository, issueId.toString).map { issue =>
callIssuesWebHook("closed", repositoryInfo, issue, baseUrl, pusherAccount)
}
}
}
}
}
Some(commit)