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(`
|
||||
|
|
|
@ -108,10 +108,9 @@ func ObjectOidHandler(ctx *context.Context) {
|
|||
}
|
||||
|
||||
func getAuthenticatedRepoAndMeta(ctx *context.Context, rv *RequestVars, requireWrite bool) (*models.LFSMetaObject, *models.Repository) {
|
||||
repositoryString := rv.User + "/" + rv.Repo
|
||||
repository, err := models.GetRepositoryByRef(repositoryString)
|
||||
repository, err := models.GetRepositoryByOwnerAndName(rv.User, rv.Repo)
|
||||
if err != nil {
|
||||
log.Debug("Could not find repository: %s - %s", repositoryString, err)
|
||||
log.Debug("Could not find repository: %s/%s - %s", rv.User, rv.Repo, err)
|
||||
writeStatus(ctx, 404)
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -197,7 +196,6 @@ func getMetaHandler(ctx *context.Context) {
|
|||
|
||||
// PostHandler instructs the client how to upload data
|
||||
func PostHandler(ctx *context.Context) {
|
||||
|
||||
if !setting.LFS.StartServer {
|
||||
writeStatus(ctx, 404)
|
||||
return
|
||||
|
@ -210,10 +208,9 @@ func PostHandler(ctx *context.Context) {
|
|||
|
||||
rv := unpack(ctx)
|
||||
|
||||
repositoryString := rv.User + "/" + rv.Repo
|
||||
repository, err := models.GetRepositoryByRef(repositoryString)
|
||||
repository, err := models.GetRepositoryByOwnerAndName(rv.User, rv.Repo)
|
||||
if err != nil {
|
||||
log.Debug("Could not find repository: %s - %s", repositoryString, err)
|
||||
log.Debug("Could not find repository: %s/%s - %s", rv.User, rv.Repo, err)
|
||||
writeStatus(ctx, 404)
|
||||
return
|
||||
}
|
||||
|
@ -261,12 +258,10 @@ func BatchHandler(ctx *context.Context) {
|
|||
|
||||
// Create a response object
|
||||
for _, object := range bv.Objects {
|
||||
|
||||
repositoryString := object.User + "/" + object.Repo
|
||||
repository, err := models.GetRepositoryByRef(repositoryString)
|
||||
repository, err := models.GetRepositoryByOwnerAndName(object.User, object.Repo)
|
||||
|
||||
if err != nil {
|
||||
log.Debug("Could not find repository: %s - %s", repositoryString, err)
|
||||
log.Debug("Could not find repository: %s/%s - %s", object.User, object.Repo, err)
|
||||
writeStatus(ctx, 404)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue