@@ -204,18 +204,18 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
204204 }
205205
206206 if compareReq .HeadOwner == "" {
207- if compareReq .HeadRepoName == "" {
208- ci .HeadRepo = baseRepo
209- } else {
207+ if compareReq .HeadRepoName != "" { // unsupported syntax
210208 ctx .NotFound (nil )
211209 return nil
212210 }
211+
212+ ci .HeadUser = baseRepo .Owner
213+ ci .HeadRepo = baseRepo
213214 } else {
214- var headUser * user_model.User
215215 if compareReq .HeadOwner == ctx .Repo .Owner .Name {
216- headUser = ctx .Repo .Owner
216+ ci . HeadUser = ctx .Repo .Owner
217217 } else {
218- headUser , err = user_model .GetUserByName (ctx , compareReq .HeadOwner )
218+ ci . HeadUser , err = user_model .GetUserByName (ctx , compareReq .HeadOwner )
219219 if err != nil {
220220 if user_model .IsErrUserNotExist (err ) {
221221 ctx .NotFound (nil )
@@ -226,16 +226,16 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
226226 }
227227 }
228228 if compareReq .HeadRepoName == "" {
229- ci .HeadRepo = repo_model .GetForkedRepo (ctx , headUser .ID , baseRepo .ID )
230- if ci .HeadRepo == nil && headUser .ID != baseRepo .OwnerID {
229+ ci .HeadRepo = repo_model .GetForkedRepo (ctx , ci . HeadUser .ID , baseRepo .ID )
230+ if ci .HeadRepo == nil && ci . HeadUser .ID != baseRepo .OwnerID {
231231 err = baseRepo .GetBaseRepo (ctx )
232232 if err != nil {
233233 ctx .ServerError ("GetBaseRepo" , err )
234234 return nil
235235 }
236236
237237 // Check if baseRepo's base repository is the same as headUser's repository.
238- if baseRepo .BaseRepo == nil || baseRepo .BaseRepo .OwnerID != headUser .ID {
238+ if baseRepo .BaseRepo == nil || baseRepo .BaseRepo .OwnerID != ci . HeadUser .ID {
239239 log .Trace ("parseCompareInfo[%d]: does not have fork or in same repository" , baseRepo .ID )
240240 ctx .NotFound (nil )
241241 return nil
@@ -247,7 +247,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
247247 if compareReq .HeadOwner == ctx .Repo .Owner .Name && compareReq .HeadRepoName == ctx .Repo .Repository .Name {
248248 ci .HeadRepo = ctx .Repo .Repository
249249 } else {
250- ci .HeadRepo , err = repo_model .GetRepositoryByName (ctx , headUser .ID , compareReq .HeadRepoName )
250+ ci .HeadRepo , err = repo_model .GetRepositoryByName (ctx , ci . HeadUser .ID , compareReq .HeadRepoName )
251251 if err != nil {
252252 if repo_model .IsErrRepoNotExist (err ) {
253253 ctx .NotFound (nil )
0 commit comments