Fix panic when no master branch

This commit is contained in:
Unknown 2014-05-01 12:03:10 -04:00
parent 0a187dbef5
commit 75109bbd65
6 changed files with 24 additions and 13 deletions

View file

@ -194,9 +194,17 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
}
} else {
refName = ctx.Repo.Repository.DefaultBranch
if len(refName) == 0 {
refName = "master"
if gitRepo.IsBranchExist(ctx.Repo.Repository.DefaultBranch) {
refName = ctx.Repo.Repository.DefaultBranch
} else {
brs, err := gitRepo.GetBranches()
if err != nil {
ctx.Handle(500, "RepoAssignment(GetBranches))", err)
return
}
refName = brs[0]
}
}
goto detect
}