mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
show tags on commits page. refs #1973
This commit is contained in:
@@ -239,6 +239,10 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
||||||
git =>
|
git =>
|
||||||
|
def getTags(sha: String): List[String] = {
|
||||||
|
JGitUtil.getTagsOnCommit(git, sha)
|
||||||
|
}
|
||||||
|
|
||||||
JGitUtil.getCommitLog(git, branchName, page, 30, path) match {
|
JGitUtil.getCommitLog(git, branchName, page, 30, path) match {
|
||||||
case Right((logs, hasNext)) =>
|
case Right((logs, hasNext)) =>
|
||||||
html.commits(
|
html.commits(
|
||||||
@@ -252,7 +256,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
hasNext,
|
hasNext,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
getStatuses,
|
getStatuses,
|
||||||
getSummary
|
getSummary,
|
||||||
|
getTags
|
||||||
)
|
)
|
||||||
case Left(_) => NotFound()
|
case Left(_) => NotFound()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -761,7 +761,27 @@ object JGitUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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] =
|
def getTagsOfCommit(git: Git, commitId: String): List[String] =
|
||||||
using(new RevWalk(git.getRepository)) { revWalk =>
|
using(new RevWalk(git.getRepository)) { revWalk =>
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
hasNext: Boolean,
|
hasNext: Boolean,
|
||||||
hasWritePermission: Boolean,
|
hasWritePermission: Boolean,
|
||||||
getStatuses: String => List[gitbucket.core.model.CommitStatus],
|
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
|
@import gitbucket.core.view.helpers
|
||||||
@gitbucket.core.html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
|
@gitbucket.core.html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
|
||||||
@gitbucket.core.html.menu("files", repository){
|
@gitbucket.core.html.menu("files", repository){
|
||||||
@@ -39,6 +40,16 @@
|
|||||||
@if(i != 0){ <tr> }
|
@if(i != 0){ <tr> }
|
||||||
<td>
|
<td>
|
||||||
<div class="pull-right text-right">
|
<div class="pull-right text-right">
|
||||||
|
@defining(getTags(commit.id)) { tags =>
|
||||||
|
@if(tags.nonEmpty){
|
||||||
|
<span class="muted">
|
||||||
|
<i class="octicon octicon-tag"></i>
|
||||||
|
@tags.map { tag =>
|
||||||
|
<a href="@helpers.url(repository)/tree/@tag" class="tag">@tag</a>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
<a href="@helpers.url(repository)/commit/@commit.id" class="monospace commit-message strong"><i class="octicon octicon-diff" style="color: black;"></i>@commit.id.substring(0, 7)</a><br>
|
<a href="@helpers.url(repository)/commit/@commit.id" class="monospace commit-message strong"><i class="octicon octicon-diff" style="color: black;"></i>@commit.id.substring(0, 7)</a><br>
|
||||||
<a href="@helpers.url(repository)/tree/@commit.id" class="button-link">Browse files »</a>
|
<a href="@helpers.url(repository)/tree/@commit.id" class="button-link">Browse files »</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user