Grouping commit comments

This commit is contained in:
Naoki Takezoe
2018-04-19 13:05:25 +09:00
parent 1a0f282f23
commit f1db6e3c7c
4 changed files with 24 additions and 9 deletions

View File

@@ -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 @@ trait PullRequestsControllerBase extends ControllerBase {
.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,

View File

@@ -1,4 +1,5 @@
package gitbucket.core.model
import java.util.Date
trait Comment {
val commentedUserName: String
@@ -87,3 +88,10 @@ case class CommitComment(
updatedDate: java.util.Date,
issueId: Option[Int]
) extends Comment
case class CommitComments(
fileName: String,
commentedUserName: String,
registeredDate: Date,
comments: Seq[CommitComment]
) extends Comment

View File

@@ -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
<table class="table table-bordered">

View File

@@ -90,7 +90,7 @@
</div>
<div class="tab-pane" id="commits">
@if(commits.nonEmpty){
@gitbucket.core.pulls.html.commits(dayByDayCommits, Some(comments), repository)
@gitbucket.core.pulls.html.commits(dayByDayCommits, repository)
}
</div>
<div class="tab-pane" id="files">