(refs #2)Experimental implementation of forking repository.

This commit is contained in:
takezoe
2013-07-11 18:49:03 +09:00
parent 5e1eb39b87
commit 6dd1299dff
7 changed files with 65 additions and 27 deletions

View File

@@ -502,4 +502,29 @@ object JGitUtil {
}
}
def initRepository(dir: java.io.File): Unit = {
val repository = new RepositoryBuilder().setGitDir(dir).setBare.build
try {
repository.create
setReceivePack(repository)
} finally {
repository.close
}
}
def cloneRepository(from: java.io.File, to: java.io.File): Unit = {
val git = Git.cloneRepository.setURI(from.toURI.toString).setDirectory(to).setBare(true).call
try {
setReceivePack(git.getRepository)
} finally {
git.getRepository.close
}
}
private def setReceivePack(repository: org.eclipse.jgit.lib.Repository): Unit = {
val config = repository.getConfig
config.setBoolean("http", null, "receivepack", true)
config.save
}
}