From 479ef5c3794ed47ac02771816b1c88c9a509cbb7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 7 Jun 2020 19:30:58 +0200 Subject: [PATCH] In File Create/Update API return 404 if Branch does not exist (#11791) --- routers/api/v1/repo/file.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 73b8e31a4..a43fdb074 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -350,6 +350,10 @@ func handleCreateOrUpdateFileError(ctx *context.APIContext, err error) { ctx.Error(http.StatusUnprocessableEntity, "Invalid", err) return } + if models.IsErrBranchDoesNotExist(err) || git.IsErrBranchNotExist(err) { + ctx.Error(http.StatusNotFound, "BranchDoesNotExist", err) + return + } ctx.Error(http.StatusInternalServerError, "UpdateFile", err) }