1
0
Fork 0
forked from forgejo/forgejo

Fix uppercase default branch bug (#1965)

This commit is contained in:
Ethan Koenig 2017-06-13 20:42:36 -04:00 committed by Lunny Xiao
parent 96152c38b1
commit 5e92b82ac6
4 changed files with 65 additions and 3 deletions

View file

@ -480,9 +480,11 @@ func ProtectedBranchPost(ctx *context.Context) {
return
}
branch := strings.ToLower(ctx.Query("branch"))
if ctx.Repo.GitRepo.IsBranchExist(branch) &&
repo.DefaultBranch != branch {
branch := ctx.Query("branch")
if !ctx.Repo.GitRepo.IsBranchExist(branch) {
ctx.Status(404)
return
} else if repo.DefaultBranch != branch {
repo.DefaultBranch = branch
if err := ctx.Repo.GitRepo.SetDefaultBranch(branch); err != nil {
if !git.IsErrUnsupportedVersion(err) {