Get all data from the bare repository.

Cloned repositories in backend is not necessary at last.
This commit is contained in:
takezoe
2013-04-30 01:07:31 +09:00
parent 1779d167ea
commit 35f0aa7b03
5 changed files with 47 additions and 126 deletions

View File

@@ -31,12 +31,6 @@ object Directory {
def getRepositoryDir(owner: String, repository: String): File =
new File("%s/%s/%s.git".format(RepositoryHome, owner, repository))
/**
* Temporary directory which is used in the repository viewer.
*/
def getBranchDir(owner: String, repository: String, branch: String): File =
new File("%s/tmp/%s/branches/%s/%s".format(GitBucketHome, owner, repository, branch))
/**
* Temporary directory which is used in the repository creation.
* GiyBucket generates initial repository contents in this directory and push them.
@@ -44,34 +38,5 @@ object Directory {
*/
def getInitRepositoryDir(owner: String, repository: String): File =
new File("%s/tmp/%s/init-%s".format(GitBucketHome, owner, repository))
def updateAllBranches(owner: String, repository: String): Unit = {
// TODO debug log
println("[pull]" + owner + "/" + repository)
val dir = Directory.getRepositoryDir(owner, repository)
val git = Git.open(dir)
val branchList = git.branchList.call.toArray.map { ref =>
ref.asInstanceOf[Ref].getName
}.toList
branchList.foreach { branch =>
val branchName = branch.replaceFirst("^refs/heads/", "")
val branchdir = Directory.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(branchName).call
} else {
Git.open(branchdir).pull.call
}
}
}
}