From cd14d22737f14296f51f34fe0972084e79e1940e Mon Sep 17 00:00:00 2001 From: takezoe Date: Wed, 19 Jun 2013 20:07:51 +0900 Subject: [PATCH] Display parent commit id at the commit details page. --- src/main/scala/util/JGitUtil.scala | 9 ++++++--- src/main/twirl/repo/commit.scala.html | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index 2e403c001..752a496ec 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -52,10 +52,13 @@ object JGitUtil { * @param committer the commiter name * @param shortMessage the short message * @param fullMessage the full message + * @param parents the list of parent commid id */ - case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String){ - def this(rev: org.eclipse.jgit.revwalk.RevCommit) = - this(rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage) + case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String, parents: List[String]){ + + def this(rev: org.eclipse.jgit.revwalk.RevCommit) = this( + rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage, + rev.getParents().map(_.name).toList) val description = { val i = fullMessage.trim.indexOf("\n") diff --git a/src/main/twirl/repo/commit.scala.html b/src/main/twirl/repo/commit.scala.html index 0131f4594..8cd58f4fd 100644 --- a/src/main/twirl/repo/commit.scala.html +++ b/src/main/twirl/repo/commit.scala.html @@ -22,7 +22,21 @@ @commit.committer @helpers.datetime(commit.time)
+ @if(commit.parents.size == 0){ + 0 parent + } + @if(commit.parents.size == 1){ + 1 parent + @commit.parents(0).substring(0, 7) + } commit @commit.id + @if(commit.parents.size > 1){ +
+ @commit.parents.size parent + @commit.parents.map { parent => + @parent + }.mkString(" + ") + }