Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043)
* remove GetRepositoryByRef and add GetRepositoryByOwnerAndName * fix tests * fix tests bug * some improvements
This commit is contained in:
parent
674422b642
commit
35cc5b0402
7 changed files with 42 additions and 66 deletions
|
@ -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(`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue