@@ -17,7 +17,6 @@ import (
1717	"code.gitea.io/gitea/models/unit" 
1818	user_model "code.gitea.io/gitea/models/user" 
1919	"code.gitea.io/gitea/modules/git" 
20- 	"code.gitea.io/gitea/modules/gitrepo" 
2120	"code.gitea.io/gitea/modules/log" 
2221	"code.gitea.io/gitea/modules/private" 
2322	"code.gitea.io/gitea/modules/web" 
@@ -448,12 +447,27 @@ func preReceiveFor(ctx *preReceiveContext, refFullName git.RefName) {
448447
449448	baseBranchName  :=  refFullName .ForBranchName ()
450449
451- 	baseBranchExist  :=  gitrepo .IsBranchExist (ctx , ctx .Repo .Repository , baseBranchName )
450+ 	baseBranchExist , err  :=  git_model .IsBranchExist (ctx , ctx .Repo .Repository .ID , baseBranchName )
451+ 	if  err  !=  nil  {
452+ 		ctx .JSON (http .StatusInternalServerError , private.Response {
453+ 			Err : err .Error (),
454+ 		})
455+ 		return 
456+ 	}
452457
453458	if  ! baseBranchExist  {
454459		for  p , v  :=  range  baseBranchName  {
455- 			if  v  ==  '/'  &&  gitrepo .IsBranchExist (ctx , ctx .Repo .Repository , baseBranchName [:p ]) &&  p  !=  len (baseBranchName )- 1  {
456- 				baseBranchExist  =  true 
460+ 			if  v  !=  '/'  ||  p  ==  len (baseBranchName )- 1  {
461+ 				continue 
462+ 			}
463+ 			baseBranchExist , err  =  git_model .IsBranchExist (ctx , ctx .Repo .Repository .ID , baseBranchName [:p ])
464+ 			if  err  !=  nil  {
465+ 				ctx .JSON (http .StatusInternalServerError , private.Response {
466+ 					Err : err .Error (),
467+ 				})
468+ 				return 
469+ 			}
470+ 			if  baseBranchExist  {
457471				break 
458472			}
459473		}
0 commit comments