mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-04 20:45:58 +01:00
Replace existing code with JGitUtil#getRevCommitFromId().
This commit is contained in:
@@ -163,11 +163,7 @@ class RepositoryViewerController extends ControllerBase {
|
||||
val repositoryInfo = JGitUtil.getRepositoryInfo(owner, repository, servletContext)
|
||||
|
||||
val git = Git.open(getRepositoryDir(owner, repository))
|
||||
val commitId = git.getRepository.resolve(id)
|
||||
|
||||
val revWalk = new RevWalk(git.getRepository)
|
||||
val revCommit = revWalk.parseCommit(commitId)
|
||||
revWalk.dispose
|
||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||
|
||||
@scala.annotation.tailrec
|
||||
def getPathObjectId(path: String, walk: TreeWalk): ObjectId = walk.next match {
|
||||
@@ -205,11 +201,7 @@ class RepositoryViewerController extends ControllerBase {
|
||||
val id = params("id")
|
||||
|
||||
val git = Git.open(getRepositoryDir(owner, repository))
|
||||
|
||||
val revWalk = new RevWalk(git.getRepository)
|
||||
val objectId = git.getRepository.resolve(id)
|
||||
val revCommit = revWalk.parseCommit(objectId)
|
||||
revWalk.dispose
|
||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||
|
||||
repo.html.commit(id, new CommitInfo(revCommit), JGitUtil.getRepositoryInfo(owner, repository, servletContext), JGitUtil.getDiffs(git, id))
|
||||
}
|
||||
@@ -243,10 +235,7 @@ class RepositoryViewerController extends ControllerBase {
|
||||
val git = Git.open(getRepositoryDir(owner, repository))
|
||||
|
||||
// get latest commit
|
||||
val revWalk = new RevWalk(git.getRepository)
|
||||
val objectId = git.getRepository.resolve(revision)
|
||||
val revCommit = revWalk.parseCommit(objectId)
|
||||
revWalk.dispose
|
||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(revision))
|
||||
|
||||
val files = JGitUtil.getFileList(git, revision, path)
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ object JGitUtil {
|
||||
* @param commitId the ObjectId of the commit
|
||||
* @return the RevCommit for the specified commit
|
||||
*/
|
||||
def getRevCommitFromId(git: Git, commmitId: ObjectId): RevCommit = {
|
||||
def getRevCommitFromId(git: Git, commitId: ObjectId): RevCommit = {
|
||||
val revWalk = new RevWalk(git.getRepository)
|
||||
val revCommit = revWalk.parseCommit(commmitId)
|
||||
val revCommit = revWalk.parseCommit(commitId)
|
||||
revWalk.dispose
|
||||
revCommit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user