diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index b3b7685..73b308e 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -239,6 +239,10 @@ using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git => + def getTags(sha: String): List[String] = { + JGitUtil.getTagsOnCommit(git, sha) + } + JGitUtil.getCommitLog(git, branchName, page, 30, path) match { case Right((logs, hasNext)) => html.commits( @@ -252,7 +256,8 @@ hasNext, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), getStatuses, - getSummary + getSummary, + getTags ) case Left(_) => NotFound() } diff --git a/src/main/scala/gitbucket/core/util/JGitUtil.scala b/src/main/scala/gitbucket/core/util/JGitUtil.scala index bb33431..b6c8273 100644 --- a/src/main/scala/gitbucket/core/util/JGitUtil.scala +++ b/src/main/scala/gitbucket/core/util/JGitUtil.scala @@ -761,7 +761,27 @@ } /** - * Returns the list of tags of the specified commit. + * Returns the list of tags which pointed on the specified commit. + */ + def getTagsOnCommit(git: Git, commitId: String): List[String] = { + git.getRepository.getAllRefsByPeeledObjectId.asScala + .get(git.getRepository.resolve(commitId + "^0")) + .map { + _.asScala + .collect { + case x if x.getName.startsWith(Constants.R_TAGS) => + x.getName.substring(Constants.R_TAGS.length) + } + .toList + .sorted + } + .getOrElse { + List.empty + } + } + + /** + * Returns the list of tags which contains the specified commit. */ def getTagsOfCommit(git: Git, commitId: String): List[String] = using(new RevWalk(git.getRepository)) { revWalk => diff --git a/src/main/twirl/gitbucket/core/repo/commits.scala.html b/src/main/twirl/gitbucket/core/repo/commits.scala.html index 387f3d9..2596721 100644 --- a/src/main/twirl/gitbucket/core/repo/commits.scala.html +++ b/src/main/twirl/gitbucket/core/repo/commits.scala.html @@ -6,7 +6,8 @@ hasNext: Boolean, hasWritePermission: Boolean, getStatuses: String => List[gitbucket.core.model.CommitStatus], - getSummary: List[gitbucket.core.model.CommitStatus] => (gitbucket.core.model.CommitState, String))(implicit context: gitbucket.core.controller.Context) + getSummary: List[gitbucket.core.model.CommitStatus] => (gitbucket.core.model.CommitState, String), + getTags: String => List[String])(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.view.helpers @gitbucket.core.html.main(s"${repository.owner}/${repository.name}", Some(repository)) { @gitbucket.core.html.menu("files", repository){ @@ -39,6 +40,16 @@ @if(i != 0){