From a4123eae74ce89fbd699694755c6b0ce2143f4f9 Mon Sep 17 00:00:00 2001 From: takezoe Date: Sun, 5 May 2013 01:33:35 +0900 Subject: [PATCH] Fixed tags page. --- .../app/RepositoryViewerController.scala | 11 +++++++- src/main/scala/util/JGitUtil.scala | 25 +++++++++++++++---- src/main/twirl/repo/tags.scala.html | 12 ++++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/main/scala/app/RepositoryViewerController.scala b/src/main/scala/app/RepositoryViewerController.scala index 0d37b0954..5a1242dd1 100644 --- a/src/main/scala/app/RepositoryViewerController.scala +++ b/src/main/scala/app/RepositoryViewerController.scala @@ -24,7 +24,7 @@ import org.eclipse.jgit.revwalk.RevWalk * @param branchList the list of branch names * @param tags the list of tags */ -case class RepositoryInfo(owner: String, name: String, url: String, branchList: List[String], tags: List[String]) +case class RepositoryInfo(owner: String, name: String, url: String, branchList: List[String], tags: List[TagInfo]) /** * The file data for the file list of the repository viewer. @@ -61,6 +61,15 @@ case class DiffInfo(changeType: ChangeType, oldPath: String, newPath: String, ol */ case class ContentInfo(viewType: String, content: Option[String]) +/** + * The tag data. + * + * @param name the tag name + * @param time the tagged date + * @param id the commit id + */ +case class TagInfo(name: String, time: Date, id: String) + /** * The repository viewer. */ diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index 683f3660f..e703a3bf3 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -1,7 +1,7 @@ package util import org.eclipse.jgit.api.Git -import app.{RepositoryInfo, FileInfo, CommitInfo, DiffInfo} +import app.{RepositoryInfo, FileInfo, CommitInfo, DiffInfo, TagInfo} import util.Directory._ import scala.collection.JavaConverters._ import javax.servlet.ServletContext @@ -27,6 +27,20 @@ import org.eclipse.jgit.revwalk.filter.RevFilter */ object JGitUtil { + /** + * Returns RevCommit from the commit id. + * + * @param git the Git object + * @param commitId the ObjectId of the commit + * @return the RevCommit for the specified commit + */ + def getRevCommitFromId(git: Git, commmitId: ObjectId): RevCommit = { + val revWalk = new RevWalk(git.getRepository) + val revCommit = revWalk.parseCommit(commmitId) + revWalk.dispose + revCommit + } + /** * Returns the repository information. It contains branch names and tag names. */ @@ -35,12 +49,13 @@ object JGitUtil { RepositoryInfo( owner, repository, "http://localhost:8080%s/git/%s/%s.git".format(servletContext.getContextPath, owner, repository), // branches - git.branchList.call.toArray.map { ref => - ref.asInstanceOf[Ref].getName.replaceFirst("^refs/heads/", "") + git.branchList.call.asScala.map { ref => + ref.getName.replaceFirst("^refs/heads/", "") }.toList, // tags - git.tagList.call.toArray.map { ref => - ref.asInstanceOf[Ref].getName + git.tagList.call.asScala.map { ref => + val revCommit = getRevCommitFromId(git, ref.getObjectId) + TagInfo(ref.getName.replaceFirst("^refs/tags/", ""), revCommit.getCommitterIdent.getWhen, revCommit.getName) }.toList ) } diff --git a/src/main/twirl/repo/tags.scala.html b/src/main/twirl/repo/tags.scala.html index 3536f5ea4..a6b4ea3b2 100644 --- a/src/main/twirl/repo/tags.scala.html +++ b/src/main/twirl/repo/tags.scala.html @@ -6,11 +6,17 @@ @navtab("master", repository, "tags") @* TODO DON'T display branch pulldown *@

Tags

+ + + + + + @repository.tags.map { tag => - - - + + + }
TagCommitDateDownload
@tagyyyy/MM/dd HH:mm:SSxxxxxxxxxx@tag.name@helpers.datetime(tag.time)@tag.id.substring(0, 10) ZIP