diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-02 15:34:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-02 15:34:39 +0800 |
commit | 35cc5b0402d46d672e02bbe1ad15d1460077e8f4 (patch) | |
tree | 47723925eb89e286f328503ae30e77ca1eaaf021 /routers/repo/http.go | |
parent | 674422b642452050a7185f10908a9e8a86604f24 (diff) | |
download | gitea-35cc5b0402d46d672e02bbe1ad15d1460077e8f4.tar.gz gitea-35cc5b0402d46d672e02bbe1ad15d1460077e8f4.zip |
Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043)
* remove GetRepositoryByRef and add GetRepositoryByOwnerAndName
* fix tests
* fix tests bug
* some improvements
Diffstat (limited to 'routers/repo/http.go')
-rw-r--r-- | routers/repo/http.go | 18 |
1 files changed, 2 insertions, 16 deletions
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 } |