aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/commit.go
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2021-04-01 13:17:14 +0800
committerGitHub <noreply@github.com>2021-04-01 08:17:14 +0300
commit007fb00c0ec613b89e2a272f224b60c174fc78bd (patch)
tree6d830d6680da1a255a0c02697282e6f698b4b2dd /routers/repo/commit.go
parentf07b137e040dc0531ce646763a5c874547d1ac7f (diff)
downloadgitea-007fb00c0ec613b89e2a272f224b60c174fc78bd.tar.gz
gitea-007fb00c0ec613b89e2a272f224b60c174fc78bd.zip
response 404 for diff/patch of a commit that not exist (#15221)
* response 404 for diff/patch of a commit that not exist fix #15217 Signed-off-by: a1012112796 <1012112796@qq.com> * Update routers/repo/commit.go Co-authored-by: silverwind <me@silverwind.io> * use ctx.NotFound() Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'routers/repo/commit.go')
-rw-r--r--routers/repo/commit.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index c06d092613..74f1778626 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -6,6 +6,7 @@
package repo
import (
+ "errors"
"path"
"strings"
@@ -388,6 +389,11 @@ func RawDiff(ctx *context.Context) {
git.RawDiffType(ctx.Params(":ext")),
ctx.Resp,
); err != nil {
+ if git.IsErrNotExist(err) {
+ ctx.NotFound("GetRawDiff",
+ errors.New("commit "+ctx.Params(":sha")+" does not exist."))
+ return
+ }
ctx.ServerError("GetRawDiff", err)
return
}