1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

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