Show the default branch in the default.

This commit is contained in:
takezoe
2013-06-06 16:40:54 +09:00
parent 497bc61107
commit ab4cde9301

View File

@@ -230,37 +230,42 @@ trait RepositoryViewerControllerBase extends ControllerBase {
* @return HTML of the file list * @return HTML of the file list
*/ */
private def fileList(owner: String, repository: String, revstr: String = "", path: String = ".") = { private def fileList(owner: String, repository: String, revstr: String = "", path: String = ".") = {
val revision = if(revstr.isEmpty){ getRepository(owner, repository, servletContext) match {
Git.open(getRepositoryDir(owner, repository)).getRepository.getBranch case None => NotFound()
} else { case Some(repositoryInfo) => {
revstr val revision = if(revstr.isEmpty){
} repositoryInfo.repository.defaultBranch
} else {
JGitUtil.withGit(getRepositoryDir(owner, repository)){ git => revstr
// get latest commit }
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(revision))
JGitUtil.withGit(getRepositoryDir(owner, repository)){ git =>
val files = JGitUtil.getFileList(git, revision, path) // get latest commit
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(revision))
// process README.md
val readme = files.find(_.name == "README.md").map { file => val files = JGitUtil.getFileList(git, revision, path)
new String(JGitUtil.getContent(Git.open(getRepositoryDir(owner, repository)), file.id, true).get, "UTF-8")
// process README.md
val readme = files.find(_.name == "README.md").map { file =>
new String(JGitUtil.getContent(Git.open(getRepositoryDir(owner, repository)), file.id, true).get, "UTF-8")
}
repo.html.files(
// current branch
revision,
// repository
repositoryInfo,
// current path
if(path == ".") Nil else path.split("/").toList,
// latest commit
new JGitUtil.CommitInfo(revCommit),
// file list
files,
// readme
readme
)
}
} }
repo.html.files(
// current branch
revision,
// repository
getRepository(owner, repository, servletContext).get,
// current path
if(path == ".") Nil else path.split("/").toList,
// latest commit
new JGitUtil.CommitInfo(revCommit),
// file list
files,
// readme
readme
)
} }
} }