in bunch-cli/src/main/kotlin/org/jetbrains/bunches/git/git.kt [105:129]
fun create(path: String): Repository {
val pathFile = File(path)
val gitFile = if (pathFile.name == Constants.DOT_GIT) {
pathFile
} else {
File(pathFile.absolutePath, Constants.DOT_GIT)
}
if (!gitFile.exists()) {
throw ConfigureGitException(path)
}
val isWorkTree = gitFile.isFile
if (!isWorkTree) {
return FileRepositoryBuilder.create(gitFile)
}
try {
return GitRepositoryBuilder()
.setWorkTree(gitFile.parentFile)
.setGitDirFromWorkTree()
.build()
} catch (io: IOException) {
throw ConfigureGitException(path, io)
}
}