diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 0c2fd75..763fcdb 100644 --- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala +++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala @@ -538,14 +538,4 @@ hasWritePermission(owner, repoName, context.loginAccount)) } - // TODO: same as gitbucket.core.servlet.CommitLogHook ... - private def createIssueComment(owner: String, repository: String, commit: CommitInfo) = { - StringUtil.extractIssueId(commit.fullMessage).foreach { issueId => - if(getIssue(owner, repository, issueId).isDefined){ - getAccountByMailAddress(commit.committerEmailAddress).foreach { account => - createComment(owner, repository, account.userName, issueId.toInt, commit.fullMessage + " " + commit.id, "commit") - } - } - } - } } diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index 271df20..86430a9 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -1,6 +1,7 @@ package gitbucket.core.service import gitbucket.core.model.Profile._ +import gitbucket.core.util.JGitUtil.CommitInfo import gitbucket.core.util.StringUtil import profile.simple._ @@ -13,6 +14,7 @@ trait IssuesService { + self: AccountService => import IssuesService._ def getIssue(owner: String, repository: String, issueId: String)(implicit s: Session) = @@ -408,6 +410,16 @@ } } + def createIssueComment(owner: String, repository: String, commit: CommitInfo)(implicit s: Session) = { + StringUtil.extractIssueId(commit.fullMessage).foreach { issueId => + if(getIssue(owner, repository, issueId).isDefined){ + getAccountByMailAddress(commit.committerEmailAddress).foreach { account => + createComment(owner, repository, account.userName, issueId.toInt, commit.fullMessage + " " + commit.id, "commit") + } + } + } + } + } object IssuesService { diff --git a/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala b/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala index 0583f61..047e5ed 100644 --- a/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala +++ b/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala @@ -10,7 +10,6 @@ import gitbucket.core.service._ import gitbucket.core.util.ControlUtil._ import gitbucket.core.util.Implicits._ -import gitbucket.core.util.JGitUtil.CommitInfo import gitbucket.core.util._ import org.eclipse.jgit.api.Git @@ -168,7 +167,7 @@ if (!existIds.contains(commit.id) && !pushedIds.contains(commit.id)) { if (issueCount > 0) { pushedIds.add(commit.id) - createIssueComment(commit) + createIssueComment(owner, repository, commit) // close issues if(refName(1) == "heads" && branchName == defaultBranch && command.getType == ReceiveCommand.Type.UPDATE){ closeIssuesFromMessage(commit.fullMessage, pusher, owner, repository) @@ -230,13 +229,4 @@ } } - private def createIssueComment(commit: CommitInfo) = { - StringUtil.extractIssueId(commit.fullMessage).foreach { issueId => - if(getIssue(owner, repository, issueId).isDefined){ - getAccountByMailAddress(commit.committerEmailAddress).foreach { account => - createComment(owner, repository, account.userName, issueId.toInt, commit.fullMessage + " " + commit.id, "commit") - } - } - } - } }