From ac884bd7c3f454d9ea1648f807dbd4db64bdd02d Mon Sep 17 00:00:00 2001 From: takezoe Date: Thu, 12 Dec 2013 04:23:43 +0900 Subject: [PATCH] (refs #196)Fire WebHook in merging pull request from Web GUI. --- .../scala/app/PullRequestsController.scala | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/scala/app/PullRequestsController.scala b/src/main/scala/app/PullRequestsController.scala index 365fb9270..d4787e187 100644 --- a/src/main/scala/app/PullRequestsController.scala +++ b/src/main/scala/app/PullRequestsController.scala @@ -18,13 +18,14 @@ import util.JGitUtil.CommitInfo import org.slf4j.LoggerFactory import org.eclipse.jgit.merge.MergeStrategy import org.eclipse.jgit.errors.NoMergeBaseException +import service.WebHookService.WebHookPayload class PullRequestsController extends PullRequestsControllerBase - with RepositoryService with AccountService with IssuesService with PullRequestService with MilestonesService with ActivityService + with RepositoryService with AccountService with IssuesService with PullRequestService with MilestonesService with ActivityService with WebHookService with ReferrerAuthenticator with CollaboratorsAuthenticator trait PullRequestsControllerBase extends ControllerBase { - self: RepositoryService with AccountService with IssuesService with MilestonesService with ActivityService with PullRequestService + self: RepositoryService with AccountService with IssuesService with MilestonesService with ActivityService with PullRequestService with WebHookService with ReferrerAuthenticator with CollaboratorsAuthenticator => private val logger = LoggerFactory.getLogger(classOf[PullRequestsControllerBase]) @@ -163,6 +164,20 @@ trait PullRequestsControllerBase extends ControllerBase { } } + // call web hook + val webHookURLs = getWebHookURLs(owner, name) + if(webHookURLs.nonEmpty){ + val payload = WebHookPayload( + git, + loginAccount, + mergeBaseRefName, + repository, + commits.flatten.toList, + getAccountByUserName(owner).get) + + callWebHook(owner, name, webHookURLs, payload) + } + // notifications Notifier().toNotify(repository, issueId, "merge"){ Notifier.msgStatus(s"${baseUrl}/${owner}/${name}/pull/${issueId}")