mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +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 repositoryInfo = JGitUtil.getRepositoryInfo(owner, repository, servletContext)
|
||||||
|
|
||||||
val git = Git.open(getRepositoryDir(owner, repository))
|
val git = Git.open(getRepositoryDir(owner, repository))
|
||||||
val commitId = git.getRepository.resolve(id)
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
|
|
||||||
val revWalk = new RevWalk(git.getRepository)
|
|
||||||
val revCommit = revWalk.parseCommit(commitId)
|
|
||||||
revWalk.dispose
|
|
||||||
|
|
||||||
@scala.annotation.tailrec
|
@scala.annotation.tailrec
|
||||||
def getPathObjectId(path: String, walk: TreeWalk): ObjectId = walk.next match {
|
def getPathObjectId(path: String, walk: TreeWalk): ObjectId = walk.next match {
|
||||||
@@ -205,11 +201,7 @@ class RepositoryViewerController extends ControllerBase {
|
|||||||
val id = params("id")
|
val id = params("id")
|
||||||
|
|
||||||
val git = Git.open(getRepositoryDir(owner, repository))
|
val git = Git.open(getRepositoryDir(owner, repository))
|
||||||
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
val revWalk = new RevWalk(git.getRepository)
|
|
||||||
val objectId = git.getRepository.resolve(id)
|
|
||||||
val revCommit = revWalk.parseCommit(objectId)
|
|
||||||
revWalk.dispose
|
|
||||||
|
|
||||||
repo.html.commit(id, new CommitInfo(revCommit), JGitUtil.getRepositoryInfo(owner, repository, servletContext), JGitUtil.getDiffs(git, 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))
|
val git = Git.open(getRepositoryDir(owner, repository))
|
||||||
|
|
||||||
// get latest commit
|
// get latest commit
|
||||||
val revWalk = new RevWalk(git.getRepository)
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(revision))
|
||||||
val objectId = git.getRepository.resolve(revision)
|
|
||||||
val revCommit = revWalk.parseCommit(objectId)
|
|
||||||
revWalk.dispose
|
|
||||||
|
|
||||||
val files = JGitUtil.getFileList(git, revision, path)
|
val files = JGitUtil.getFileList(git, revision, path)
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ object JGitUtil {
|
|||||||
* @param commitId the ObjectId of the commit
|
* @param commitId the ObjectId of the commit
|
||||||
* @return the RevCommit for the specified 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 revWalk = new RevWalk(git.getRepository)
|
||||||
val revCommit = revWalk.parseCommit(commmitId)
|
val revCommit = revWalk.parseCommit(commitId)
|
||||||
revWalk.dispose
|
revWalk.dispose
|
||||||
revCommit
|
revCommit
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user