Fixed updating temporary files for branches.

This commit is contained in:
takezoe
2013-04-12 03:23:10 +09:00
parent 0d68578a27
commit 319f301b03

View File

@@ -133,18 +133,20 @@ class RepositoryViewerServlet extends ScalatraServlet with ServletBase {
val git = Git.open(dir) val git = Git.open(dir)
val branchList = git.branchList.call.toArray.map { ref => val branchList = git.branchList.call.toArray.map { ref =>
ref.asInstanceOf[Ref].getName.replaceFirst("^refs/heads/", "") ref.asInstanceOf[Ref].getName
}.toList }.toList
branchList.foreach { branch => branchList.foreach { branch =>
val branchdir = getBranchDir(owner, repository, branch) val branchName = branch.replaceFirst("^refs/heads/", "")
val branchdir = getBranchDir(owner, repository, branchName)
if(!branchdir.exists){ if(!branchdir.exists){
branchdir.mkdirs() branchdir.mkdirs()
Git.cloneRepository Git.cloneRepository
.setURI(dir.toURL.toString) .setURI(dir.toURL.toString)
.setBranch(branch)
.setDirectory(branchdir) .setDirectory(branchdir)
.call .call
Git.open(branchdir).checkout.setName(branch).call Git.open(branchdir).checkout.setName(branchName).call
} else { } else {
Git.open(branchdir).pull.call Git.open(branchdir).pull.call
} }