mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-06 11:15:48 +02:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user