]> source.dussan.org Git - gitea.git/commitdiff
When comparing with an non-exist repository, return 404 but 500 (#27437) (#27442)
authorGiteabot <teabot@gitea.io>
Wed, 4 Oct 2023 14:41:57 +0000 (22:41 +0800)
committerGitHub <noreply@github.com>
Wed, 4 Oct 2023 14:41:57 +0000 (14:41 +0000)
Backport #27437 by @lunny

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
routers/web/repo/compare.go

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