diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 936982a..a10ec81 100644 --- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala +++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala @@ -1,6 +1,6 @@ package gitbucket.core.controller -import gitbucket.core.model.{CommitComment, IssueComment, WebHook} +import gitbucket.core.model.{CommitComment, CommitComments, IssueComment, WebHook} import gitbucket.core.plugin.PluginRegistry import gitbucket.core.pulls.html import gitbucket.core.service.CommitStatusService @@ -123,14 +123,22 @@ .flatten .toList ::: getComments(owner, name, issueId)) .groupBy { - case x: IssueComment => (None, None, None) - case x: CommitComment => (x.fileName, x.oldLine, x.newLine) + case x: IssueComment => (Some(x.commentId), None, None, None) + case x: CommitComment => (None, x.fileName, x.oldLine, x.newLine) } - .toSeq - .sortWith { - case ((key1, comments1), (key2, comments2)) => - comments1.head.registeredDate before comments2.head.registeredDate + .toList + .map { + case ((Some(_), _, _, _), comments) => + comments.head + case ((None, Some(fileName), _, _), comments) => + CommitComments( + fileName = fileName, + commentedUserName = comments.head.commentedUserName, + registeredDate = comments.head.registeredDate, + comments = comments.map(_.asInstanceOf[CommitComment]) + ) } + .sortWith(_.registeredDate before _.registeredDate) html.pullreq( issue, diff --git a/src/main/scala/gitbucket/core/model/Comment.scala b/src/main/scala/gitbucket/core/model/Comment.scala index 8f79a52..b356a1e 100644 --- a/src/main/scala/gitbucket/core/model/Comment.scala +++ b/src/main/scala/gitbucket/core/model/Comment.scala @@ -1,4 +1,5 @@ package gitbucket.core.model +import java.util.Date trait Comment { val commentedUserName: String @@ -87,3 +88,10 @@ updatedDate: java.util.Date, issueId: Option[Int] ) extends Comment + +case class CommitComments( + fileName: String, + commentedUserName: String, + registeredDate: Date, + comments: Seq[CommitComment] +) extends Comment diff --git a/src/main/twirl/gitbucket/core/pulls/commits.scala.html b/src/main/twirl/gitbucket/core/pulls/commits.scala.html index 7138fc8..bb65323 100644 --- a/src/main/twirl/gitbucket/core/pulls/commits.scala.html +++ b/src/main/twirl/gitbucket/core/pulls/commits.scala.html @@ -1,5 +1,4 @@ @(commits: Seq[Seq[gitbucket.core.util.JGitUtil.CommitInfo]], - comments: Option[List[gitbucket.core.model.Comment]] = None, repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.view.helpers