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 branchList = git.branchList.call.toArray.map { ref =>
ref.asInstanceOf[Ref].getName.replaceFirst("^refs/heads/", "")
ref.asInstanceOf[Ref].getName
}.toList
branchList.foreach { branch =>
val branchdir = getBranchDir(owner, repository, branch)
val branchName = branch.replaceFirst("^refs/heads/", "")
val branchdir = getBranchDir(owner, repository, branchName)
if(!branchdir.exists){
branchdir.mkdirs()
Git.cloneRepository
.setURI(dir.toURL.toString)
.setBranch(branch)
.setDirectory(branchdir)
.call
Git.open(branchdir).checkout.setName(branch).call
Git.open(branchdir).checkout.setName(branchName).call
} else {
Git.open(branchdir).pull.call
}