Merge tags and releases

This commit is contained in:
Naoki Takezoe
2018-01-13 16:19:02 +09:00
parent 71cce5b470
commit e80da63515
4 changed files with 11 additions and 59 deletions

View File

@@ -628,7 +628,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
* Displays tags.
*/
get("/:owner/:repository/tags")(referrersOnly { repository =>
html.tags(repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
redirect(s"${repository.owner}/${repository.name}/releases")
})
/**

View File

@@ -229,10 +229,6 @@ trait RepositoryService { self: AccountService =>
t.byRepository(repository.userName, repository.repositoryName) && (t.closed === false.bind)
}.map(_.pullRequest).list
val releases = Releases.filter { t =>
t.byRepository(repository.userName, repository.repositoryName)
}.list
new RepositoryInfo(
JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName),
repository,
@@ -242,7 +238,6 @@ trait RepositoryService { self: AccountService =>
repository.originUserName.getOrElse(repository.userName),
repository.originRepositoryName.getOrElse(repository.repositoryName)
),
releases.length,
getRepositoryManagers(repository.userName))
}
}
@@ -515,20 +510,20 @@ trait RepositoryService { self: AccountService =>
object RepositoryService {
case class RepositoryInfo(owner: String, name: String, repository: Repository,
issueCount: Int, pullCount: Int, forkedCount: Int, releaseCount: Int,
issueCount: Int, pullCount: Int, forkedCount: Int,
branchList: Seq[String], tags: Seq[JGitUtil.TagInfo], managers: Seq[String]) {
/**
* Creates instance with issue count and pull request count.
*/
def this(repo: JGitUtil.RepositoryInfo, model: Repository, issueCount: Int, pullCount: Int, forkedCount: Int, releaseCount: Int, managers: Seq[String]) =
this(repo.owner, repo.name, model, issueCount, pullCount, forkedCount, releaseCount, repo.branchList, repo.tags, managers)
def this(repo: JGitUtil.RepositoryInfo, model: Repository, issueCount: Int, pullCount: Int, forkedCount: Int, managers: Seq[String]) =
this(repo.owner, repo.name, model, issueCount, pullCount, forkedCount, repo.branchList, repo.tags, managers)
/**
* Creates instance without issue, pull request and release count.
* Creates instance without issue and pull request count.
*/
def this(repo: JGitUtil.RepositoryInfo, model: Repository, forkedCount: Int, managers: Seq[String]) =
this(repo.owner, repo.name, model, 0, 0, forkedCount, 0, repo.branchList, repo.tags, managers)
this(repo.owner, repo.name, model, 0, 0, forkedCount, repo.branchList, repo.tags, managers)
def httpUrl(implicit context: Context): String = RepositoryService.httpUrl(owner, name)
def sshUrl(implicit context: Context): Option[String] = RepositoryService.sshUrl(owner, name)
@@ -542,9 +537,10 @@ object RepositoryService {
(id, path.substring(id.length).stripPrefix("/"))
}
def getReleaseByTag(tag: String)(implicit s: Session): Option[Release] = {
Releases filter (_.byTag(owner, name, tag)) firstOption
}
// def getReleaseByTag(tag: String)(implicit s: Session): Option[Release] = {
// Releases filter (_.byTag(owner, name, tag)) firstOption
// }
}
def httpUrl(owner: String, name: String)(implicit context: Context): String = s"${context.baseUrl}/git/${owner}/${name}.git"

View File

@@ -33,9 +33,8 @@
@menuitem("", "files", "Files", "code")
@if(repository.branchList.nonEmpty) {
@menuitem("/branches", "branches", "Branches", "git-branch", repository.branchList.length)
@menuitem("/tags", "tags", "Tags", "tag", repository.tags.length)
}
@menuitem("/releases", "releases", "Releases", "gift", repository.releaseCount)
@menuitem("/releases", "releases", "Releases", "tag", repository.tags.length)
@if(repository.repository.options.issuesOption != "DISABLE") {
@menuitem("/issues", "issues", "Issues", "issue-opened", repository.issueCount)
@menuitem("/pulls", "pulls", "Pull requests", "git-pull-request", repository.pullCount)

View File

@@ -1,43 +0,0 @@
@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo, hasWritePermission: Boolean)(implicit context: gitbucket.core.controller.Context, s: gitbucket.core.model.Profile.profile.blockingApi.Session)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
@gitbucket.core.html.menu("tags", repository){
<table class="table table-bordered">
<thead>
<tr>
<th width="40%">Tag</th>
<th width="15%">Date</th>
<th width="15%">Commit</th>
<th width="15%">Download</th>
<th width="15%">Release</th>
</tr>
</thead>
<tbody>
@repository.tags.reverseMap { tag =>
<tr>
<td><a href="@helpers.url(repository)/tree/@helpers.encodeRefName(tag.name)">@tag.name</a></td>
<td>@gitbucket.core.helper.html.datetimeago(tag.time, false)</td>
<td class="monospace"><a href="@helpers.url(repository)/commit/@tag.id">@tag.id.substring(0, 10)</a></td>
<td>
<a href="@helpers.url(repository)/archive/@{helpers.encodeRefName(tag.name)}.zip">ZIP</a>
<a href="@helpers.url(repository)/archive/@{helpers.encodeRefName(tag.name)}.tar.gz">TAR.GZ</a>
</td>
<td>
@repository.getReleaseByTag(tag.name).map{ release =>
<a href="@helpers.url(repository)/releases/@release.releaseId">Release</a>
}.getOrElse{
@if(hasWritePermission){
<div class="show-title pull-right">
<a class="btn btn-success btn-min" href="@helpers.url(repository)/releases/@{helpers.encodeRefName(tag.name)}/create">Create release</a>
</div>
} else {
<br />
}
}
</td>
</tr>
}
</tbody>
</table>
}
}