Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043)

* remove GetRepositoryByRef and add GetRepositoryByOwnerAndName

* fix tests

* fix tests bug

* some improvements
This commit is contained in:
Lunny Xiao 2017-12-02 15:34:39 +08:00 committed by GitHub
parent 674422b642
commit 35cc5b0402
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 66 deletions

View file

@ -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
}