mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 13:05:50 +01:00
Move getBranchesOfCommit and getTagsOfCommit to JGitUtil.
This commit is contained in:
@@ -158,27 +158,10 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
JGitUtil.withGit(getRepositoryDir(owner, repository)){ git =>
|
||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
import org.eclipse.jgit.lib.Constants
|
||||
val walk = new org.eclipse.jgit.revwalk.RevWalk(git.getRepository)
|
||||
val commit = walk.parseCommit(git.getRepository.resolve(revCommit.getName + "^0"))
|
||||
|
||||
// TODO move to JGitUtil
|
||||
val branchs = git.getRepository.getAllRefs.entrySet.asScala.filter { e =>
|
||||
(e.getKey.startsWith(Constants.R_HEADS) && walk.isMergedInto(commit, walk.parseCommit(e.getValue.getObjectId)))
|
||||
}.map { e =>
|
||||
e.getValue.getName.substring(org.eclipse.jgit.lib.Constants.R_HEADS.length)
|
||||
}.toList.sorted
|
||||
|
||||
// TODO move to JGitUtil
|
||||
val tags = git.getRepository.getAllRefs.entrySet.asScala.filter { e =>
|
||||
(e.getKey.startsWith(Constants.R_TAGS) && walk.isMergedInto(commit, walk.parseCommit(e.getValue.getObjectId)))
|
||||
}.map { e =>
|
||||
e.getValue.getName.substring(org.eclipse.jgit.lib.Constants.R_TAGS.length)
|
||||
}.toList.sorted.reverse
|
||||
|
||||
repo.html.commit(id, new JGitUtil.CommitInfo(revCommit), branchs, tags,
|
||||
getRepository(owner, repository, baseUrl).get, JGitUtil.getDiffs(git, id))
|
||||
repo.html.commit(id, new JGitUtil.CommitInfo(revCommit),
|
||||
JGitUtil.getBranchesOfCommit(git, revCommit.getName),
|
||||
JGitUtil.getTagsOfCommit(git, revCommit.getName),
|
||||
getRepository(owner, repository, baseUrl).get, JGitUtil.getDiffs(git, id))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user