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 --- cmd/serv.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'cmd') diff --git a/cmd/serv.go b/cmd/serv.go index 5dc3785852..1ff296d007 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -158,18 +158,10 @@ func runServ(c *cli.Context) error { } os.Setenv(models.EnvRepoName, reponame) - repoUser, err := models.GetUserByName(username) - if err != nil { - if models.IsErrUserNotExist(err) { - fail("Repository owner does not exist", "Unregistered owner: %s", username) - } - fail("Internal error", "Failed to get repository owner (%s): %v", username, err) - } - - repo, err := models.GetRepositoryByName(repoUser.ID, reponame) + repo, err := models.GetRepositoryByOwnerAndName(username, reponame) if err != nil { if models.IsErrRepoNotExist(err) { - fail(accessDenied, "Repository does not exist: %s/%s", repoUser.Name, reponame) + fail(accessDenied, "Repository does not exist: %s/%s", username, reponame) } fail("Internal error", "Failed to get repository: %v", err) } @@ -263,7 +255,7 @@ func runServ(c *cli.Context) error { //LFS token authentication if verb == lfsAuthenticateVerb { - url := fmt.Sprintf("%s%s/%s.git/info/lfs", setting.AppURL, repoUser.Name, repo.Name) + url := fmt.Sprintf("%s%s/%s.git/info/lfs", setting.AppURL, username, repo.Name) now := time.Now() token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ -- cgit v1.2.3