mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-16 11:00:02 +02:00
Fix panic when no master branch
This commit is contained in:
parent
0a187dbef5
commit
75109bbd65
6 changed files with 24 additions and 13 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue