summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-12-02 15:34:39 +0800
committerGitHub <noreply@github.com>2017-12-02 15:34:39 +0800
commit35cc5b0402d46d672e02bbe1ad15d1460077e8f4 (patch)
tree47723925eb89e286f328503ae30e77ca1eaaf021 /cmd
parent674422b642452050a7185f10908a9e8a86604f24 (diff)
downloadgitea-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 'cmd')
-rw-r--r--cmd/serv.go14
1 files changed, 3 insertions, 11 deletions
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{