diff options
author | Giteabot <teabot@gitea.io> | 2023-10-04 22:41:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-04 14:41:57 +0000 |
commit | a9d547f55b5e929e902e4d3d72d13d1f62f57741 (patch) | |
tree | cead4d75ad36ed926ee6db502a3d1e1ebd331943 | |
parent | 51001d9ffed27b871acb1b1c27f4090b3dbb026d (diff) | |
download | gitea-a9d547f55b5e929e902e4d3d72d13d1f62f57741.tar.gz gitea-a9d547f55b5e929e902e4d3d72d13d1f62f57741.zip |
When comparing with an non-exist repository, return 404 but 500 (#27437) (#27442)
Backport #27437 by @lunny
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r-- | routers/web/repo/compare.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index ecc8e66702..9af1d60c29 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -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 |