mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 05:25:50 +01:00
Fixed tags page.
This commit is contained in:
@@ -24,7 +24,7 @@ import org.eclipse.jgit.revwalk.RevWalk
|
|||||||
* @param branchList the list of branch names
|
* @param branchList the list of branch names
|
||||||
* @param tags the list of tags
|
* @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.
|
* 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])
|
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.
|
* The repository viewer.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import app.{RepositoryInfo, FileInfo, CommitInfo, DiffInfo}
|
import app.{RepositoryInfo, FileInfo, CommitInfo, DiffInfo, TagInfo}
|
||||||
import util.Directory._
|
import util.Directory._
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
import javax.servlet.ServletContext
|
import javax.servlet.ServletContext
|
||||||
@@ -27,6 +27,20 @@ import org.eclipse.jgit.revwalk.filter.RevFilter
|
|||||||
*/
|
*/
|
||||||
object JGitUtil {
|
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.
|
* Returns the repository information. It contains branch names and tag names.
|
||||||
*/
|
*/
|
||||||
@@ -35,12 +49,13 @@ object JGitUtil {
|
|||||||
RepositoryInfo(
|
RepositoryInfo(
|
||||||
owner, repository, "http://localhost:8080%s/git/%s/%s.git".format(servletContext.getContextPath, owner, repository),
|
owner, repository, "http://localhost:8080%s/git/%s/%s.git".format(servletContext.getContextPath, owner, repository),
|
||||||
// branches
|
// branches
|
||||||
git.branchList.call.toArray.map { ref =>
|
git.branchList.call.asScala.map { ref =>
|
||||||
ref.asInstanceOf[Ref].getName.replaceFirst("^refs/heads/", "")
|
ref.getName.replaceFirst("^refs/heads/", "")
|
||||||
}.toList,
|
}.toList,
|
||||||
// tags
|
// tags
|
||||||
git.tagList.call.toArray.map { ref =>
|
git.tagList.call.asScala.map { ref =>
|
||||||
ref.asInstanceOf[Ref].getName
|
val revCommit = getRevCommitFromId(git, ref.getObjectId)
|
||||||
|
TagInfo(ref.getName.replaceFirst("^refs/tags/", ""), revCommit.getCommitterIdent.getWhen, revCommit.getName)
|
||||||
}.toList
|
}.toList
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,17 @@
|
|||||||
@navtab("master", repository, "tags") @* TODO DON'T display branch pulldown *@
|
@navtab("master", repository, "tags") @* TODO DON'T display branch pulldown *@
|
||||||
<h1>Tags</h1>
|
<h1>Tags</h1>
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
|
<tr>
|
||||||
|
<th width="40%">Tag</th>
|
||||||
|
<th width="20%">Commit</th>
|
||||||
|
<th width="20%">Date</th>
|
||||||
|
<th width="20%">Download</th>
|
||||||
|
</tr>
|
||||||
@repository.tags.map { tag =>
|
@repository.tags.map { tag =>
|
||||||
<tr>
|
<tr>
|
||||||
<td>@tag</td>
|
<td>@tag.name</td>
|
||||||
<td>yyyy/MM/dd HH:mm:SS</td>
|
<td>@helpers.datetime(tag.time)</td>
|
||||||
<td><a href="">xxxxxxxxxx</a></td>
|
<td><a href="@path/@repository.owner/@repository.name/tree/@tag.id">@tag.id.substring(0, 10)</a></td>
|
||||||
<td><a href="">ZIP</a></td>
|
<td><a href="">ZIP</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user