From 1a0f282f2367d232153772f2b2929821c3eb6b7c Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 18 Apr 2018 18:47:00 +0900 Subject: [PATCH] Improve pull request comments presentation --- .../controller/PullRequestsController.scala | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 8fea20086..936982af6 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.WebHook +import gitbucket.core.model.{CommitComment, IssueComment, WebHook} import gitbucket.core.plugin.PluginRegistry import gitbucket.core.pulls.html import gitbucket.core.service.CommitStatusService @@ -117,14 +117,25 @@ trait PullRequestsControllerBase extends ControllerBase { git => val (commits, diffs) = getRequestCompareInfo(owner, name, pullreq.commitIdFrom, owner, name, pullreq.commitIdTo) + + val comments = (commits.flatten + .map(commit => getCommitComments(owner, name, commit.id, true)) + .flatten + .toList ::: getComments(owner, name, issueId)) + .groupBy { + case x: IssueComment => (None, None, None) + case x: CommitComment => (x.fileName, x.oldLine, x.newLine) + } + .toSeq + .sortWith { + case ((key1, comments1), (key2, comments2)) => + comments1.head.registeredDate before comments2.head.registeredDate + } + html.pullreq( issue, pullreq, - (commits.flatten - .map(commit => getCommitComments(owner, name, commit.id, true)) - .flatten - .toList ::: getComments(owner, name, issueId)) - .sortWith((a, b) => a.registeredDate before b.registeredDate), + comments, getIssueLabels(owner, name, issueId), getAssignableUserNames(owner, name), getMilestonesWithIssueCount(owner, name),