@@ -1096,23 +1096,20 @@ type parseCompareInfoResult struct {
10961096}
10971097
10981098// parseCompareInfo returns non-nil if it succeeds, it always writes to the context and returns nil if it fails
1099- func parseCompareInfo (ctx * context.APIContext , form api.CreatePullRequestOption ) (result * parseCompareInfoResult , closer func () error ) {
1099+ func parseCompareInfo (ctx * context.APIContext , form api.CreatePullRequestOption ) (result * parseCompareInfoResult , closer func ()) {
11001100 var err error
11011101 // Get compared branches information
11021102 // format: <base branch>...[<head repo>:]<head branch>
11031103 // base<-head: master...head:feature
11041104 // same repo: master...feature
11051105 baseRepo := ctx .Repo .Repository
11061106 baseRefToGuess := form .Base
1107- headRefToGuess := form .Head
1108-
1109- var headUser * user_model.User
11101107
1111- headInfos := strings .Split (form .Head , ":" )
1112- if len (headInfos ) == 1 {
1108+ headUser := ctx .Repo .Owner
1109+ headRefToGuess := form .Head
1110+ if headInfos := strings .Split (form .Head , ":" ); len (headInfos ) == 1 {
11131111 // If there is no head repository, it means pull request between same repository.
1114- headUser = ctx .Repo .Owner
1115- headRefToGuess = headInfos [0 ]
1112+ // Do nothing here because the head variables have been assigned above.
11161113 } else if len (headInfos ) == 2 {
11171114 // There is a head repository (the head repository could also be the same base repo)
11181115 headRefToGuess = headInfos [1 ]
@@ -1155,14 +1152,14 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
11551152 if isSameRepo {
11561153 headRepo = ctx .Repo .Repository
11571154 headGitRepo = ctx .Repo .GitRepo
1158- closer = func () error { return nil } // no need to close the head repo because it shares the base repo
1155+ closer = func () { } // no need to close the head repo because it shares the base repo
11591156 } else {
11601157 headGitRepo , err = gitrepo .OpenRepository (ctx , headRepo )
11611158 if err != nil {
11621159 ctx .Error (http .StatusInternalServerError , "OpenRepository" , err )
11631160 return nil , nil
11641161 }
1165- closer = headGitRepo .Close
1162+ closer = func () { _ = headGitRepo .Close () }
11661163 }
11671164 defer func () {
11681165 if result == nil && ! isSameRepo {
0 commit comments