mirror of
1
Fork 0

When comparing with an non-exist repository, return 404 but 500 (#27437) (#27441)

Backport #27437 by @lunny

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
(cherry picked from commit 973b7f6298)
This commit is contained in:
Giteabot 2023-10-04 22:27:42 +08:00 committed by Earl Warren
parent 915c60f8c1
commit c50af699ea
No known key found for this signature in database
GPG Key ID: 0579CB2928A78A00
1 changed files with 3 additions and 1 deletions

View File

@ -251,7 +251,6 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
isSameRepo = true isSameRepo = true
ci.HeadUser = ctx.Repo.Owner ci.HeadUser = ctx.Repo.Owner
ci.HeadBranch = headInfos[0] ci.HeadBranch = headInfos[0]
} else if len(headInfos) == 2 { } else if len(headInfos) == 2 {
headInfosSplit := strings.Split(headInfos[0], "/") headInfosSplit := strings.Split(headInfos[0], "/")
if len(headInfosSplit) == 1 { if len(headInfosSplit) == 1 {
@ -406,6 +405,9 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
return nil return nil
} }
defer ci.HeadGitRepo.Close() defer ci.HeadGitRepo.Close()
} else {
ctx.NotFound("ParseCompareInfo", nil)
return nil
} }
ctx.Data["HeadRepo"] = ci.HeadRepo ctx.Data["HeadRepo"] = ci.HeadRepo