summaryrefslogtreecommitdiffstats
path: root/modules/context
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 /modules/context
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 'modules/context')
-rw-r--r--modules/context/context.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index 6fb0a2cde3..10a84cd9b1 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -176,12 +176,9 @@ func Contexter() macaron.Handler {
repoName := c.Params(":reponame")
branchName := "master"
- owner, err := models.GetUserByName(ownerName)
- if err == nil {
- repo, err := models.GetRepositoryByName(owner.ID, repoName)
- if err == nil && len(repo.DefaultBranch) > 0 {
- branchName = repo.DefaultBranch
- }
+ repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName)
+ if err == nil && len(repo.DefaultBranch) > 0 {
+ branchName = repo.DefaultBranch
}
prefix := setting.AppURL + path.Join(ownerName, repoName, "src", "branch", branchName)
c.PlainText(http.StatusOK, []byte(com.Expand(`