mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 05:25:50 +01:00
Fix showing branch if specified branch, tag or id does not exist.
This commit is contained in:
@@ -213,11 +213,17 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
if(repository.commitCount == 0){
|
if(repository.commitCount == 0){
|
||||||
repo.html.guide(repository)
|
repo.html.guide(repository)
|
||||||
} else {
|
} else {
|
||||||
val revision = if(revstr.isEmpty) repository.repository.defaultBranch else revstr
|
|
||||||
|
|
||||||
JGitUtil.withGit(getRepositoryDir(repository.owner, repository.name)){ git =>
|
JGitUtil.withGit(getRepositoryDir(repository.owner, repository.name)){ git =>
|
||||||
// get latest commit
|
// get specified commit
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(revision))
|
val (revCommit, revision) = try {
|
||||||
|
val revision = if(revstr.isEmpty) repository.repository.defaultBranch else revstr
|
||||||
|
(JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(revision)), revision)
|
||||||
|
} catch {
|
||||||
|
case e: NullPointerException => {
|
||||||
|
val revision = repository.branchList.head
|
||||||
|
(JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(revision)), revision)
|
||||||
|
}
|
||||||
|
}
|
||||||
// get files
|
// get files
|
||||||
val files = JGitUtil.getFileList(git, revision, path)
|
val files = JGitUtil.getFileList(git, revision, path)
|
||||||
// process README.md
|
// process README.md
|
||||||
@@ -225,20 +231,10 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
new String(JGitUtil.getContent(Git.open(getRepositoryDir(repository.owner, repository.name)), file.id, true).get, "UTF-8")
|
new String(JGitUtil.getContent(Git.open(getRepositoryDir(repository.owner, repository.name)), file.id, true).get, "UTF-8")
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.html.files(
|
repo.html.files(revision, repository,
|
||||||
// current branch
|
if(path == ".") Nil else path.split("/").toList, // current path
|
||||||
revision,
|
new JGitUtil.CommitInfo(revCommit), // latest commit
|
||||||
// repository
|
files, readme)
|
||||||
repository,
|
|
||||||
// current path
|
|
||||||
if(path == ".") Nil else path.split("/").toList,
|
|
||||||
// latest commit
|
|
||||||
new JGitUtil.CommitInfo(revCommit),
|
|
||||||
// file list
|
|
||||||
files,
|
|
||||||
// readme
|
|
||||||
readme
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user