mirror of
https://github.com/go-gitea/gitea
synced 2025-07-10 04:27:22 +00:00
Fix panic when no master branch
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user