diff --git a/src/main/scala/gitbucket/core/controller/IssuesController.scala b/src/main/scala/gitbucket/core/controller/IssuesController.scala index ddd49fc..b15cd16 100644 --- a/src/main/scala/gitbucket/core/controller/IssuesController.scala +++ b/src/main/scala/gitbucket/core/controller/IssuesController.scala @@ -352,6 +352,7 @@ } } + // TODO Same method exists in PullRequestController. Should it moved to IssueService? private def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String) = { StringUtil.extractIssueId(message).foreach { issueId => val content = fromIssue.issueId + ":" + fromIssue.title diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 6cf7d4e..b0a83c7 100644 --- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala +++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala @@ -436,8 +436,14 @@ // call web hook callPullRequestWebHook("opened", repository, issueId, context.baseUrl, context.loginAccount.get) - // notifications getIssue(owner, name, issueId.toString) foreach { issue => + // extract references and create refer comment + createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse("")) + + // TODO call web hooks + //callIssuesWebHook("opened", repository, issue, context.baseUrl, context.loginAccount.get) + + // notifications Notifier().toNotify(repository, issue, form.content.getOrElse("")){ Notifier.msgPullRequest(s"${context.baseUrl}/${owner}/${name}/pull/${issueId}") } @@ -447,6 +453,19 @@ } }) + // TODO Same method exists in IssueController. Should it moved to IssueService? + private def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String) = { + StringUtil.extractIssueId(message).foreach { issueId => + val content = fromIssue.issueId + ":" + fromIssue.title + if(getIssue(owner, repository, issueId).isDefined){ + // Not add if refer comment already exist. + if(!getComments(owner, repository, issueId.toInt).exists { x => x.action == "refer" && x.content == content }) { + createComment(owner, repository, context.loginAccount.get.userName, issueId.toInt, content, "refer") + } + } + } + } + /** * Parses branch identifier and extracts owner and branch name as tuple. * diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index 67dde49..f1a6fde 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -92,7 +92,7 @@ def getCommitStatues(issueList:Seq[(String, String, Int)])(implicit s: Session) :Map[(String, String, Int), CommitStatusInfo] ={ if(issueList.isEmpty){ Map.empty - }else{ + } else { import scala.slick.jdbc._ val issueIdQuery = issueList.map(i => "(PR.USER_NAME=? AND PR.REPOSITORY_NAME=? AND PR.ISSUE_ID=?)").mkString(" OR ") implicit val qset = SetParameter[Seq[(String, String, Int)]] {