From 35cc5b0402d46d672e02bbe1ad15d1460077e8f4 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 2 Dec 2017 15:34:39 +0800 Subject: Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043) * remove GetRepositoryByRef and add GetRepositoryByOwnerAndName * fix tests * fix tests bug * some improvements --- routers/repo/http.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'routers') diff --git a/routers/repo/http.go b/routers/repo/http.go index cac1ec335f..c5b45f9cc8 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -64,23 +64,9 @@ func HTTP(ctx *context.Context) { reponame = reponame[:len(reponame)-5] } - repoUser, err := models.GetUserByName(username) + repo, err := models.GetRepositoryByOwnerAndName(username, reponame) if err != nil { - if models.IsErrUserNotExist(err) { - ctx.Handle(http.StatusNotFound, "GetUserByName", nil) - } else { - ctx.Handle(http.StatusInternalServerError, "GetUserByName", err) - } - return - } - - repo, err := models.GetRepositoryByName(repoUser.ID, reponame) - if err != nil { - if models.IsErrRepoNotExist(err) { - ctx.Handle(http.StatusNotFound, "GetRepositoryByName", nil) - } else { - ctx.Handle(http.StatusInternalServerError, "GetRepositoryByName", err) - } + ctx.NotFoundOrServerError("GetRepositoryByOwnerAndName", models.IsErrRepoNotExist, err) return } -- cgit v1.2.3