mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-07 01:26:30 +02:00
Merge pull request #768 from Mura-Mi/avoid-npe-masterless
Avoid NPE when master branch does not exist
This commit is contained in:
@@ -794,7 +794,12 @@ object JGitUtil {
|
||||
def getBranches(owner: String, name: String, defaultBranch: String): Seq[BranchInfo] = {
|
||||
using(Git.open(getRepositoryDir(owner, name))){ git =>
|
||||
val repo = git.getRepository
|
||||
val defaultObject = repo.resolve(defaultBranch)
|
||||
val defaultObject = if (repo.getAllRefs.keySet().contains(defaultBranch)) {
|
||||
repo.resolve(defaultBranch)
|
||||
} else {
|
||||
git.branchList().call().iterator().next().getObjectId
|
||||
}
|
||||
|
||||
git.branchList.call.asScala.map { ref =>
|
||||
val walk = new RevWalk(repo)
|
||||
try{
|
||||
|
||||
Reference in New Issue
Block a user