mirror of
https://github.com/go-gitea/gitea
synced 2024-11-14 14:14:25 +00:00
4247304f5a
- Update import paths from github.com/go-gitea to code.gitea.io - Fix import path for travis See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
// Copyright 2016 The Gogs Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package admin
|
|
|
|
import (
|
|
"code.gitea.io/gitea/models"
|
|
"code.gitea.io/gitea/modules/context"
|
|
)
|
|
|
|
func GetRepositoryByParams(ctx *context.APIContext) *models.Repository {
|
|
repo, err := models.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))
|
|
if err != nil {
|
|
if models.IsErrRepoNotExist(err) {
|
|
ctx.Status(404)
|
|
} else {
|
|
ctx.Error(500, "GetRepositoryByName", err)
|
|
}
|
|
return nil
|
|
}
|
|
return repo
|
|
}
|
|
|
|
func AddTeamRepository(ctx *context.APIContext) {
|
|
repo := GetRepositoryByParams(ctx)
|
|
if ctx.Written() {
|
|
return
|
|
}
|
|
if err := ctx.Org.Team.AddRepository(repo); err != nil {
|
|
ctx.Error(500, "AddRepository", err)
|
|
return
|
|
}
|
|
|
|
ctx.Status(204)
|
|
}
|
|
|
|
func RemoveTeamRepository(ctx *context.APIContext) {
|
|
repo := GetRepositoryByParams(ctx)
|
|
if ctx.Written() {
|
|
return
|
|
}
|
|
if err := ctx.Org.Team.RemoveRepository(repo.ID); err != nil {
|
|
ctx.Error(500, "RemoveRepository", err)
|
|
return
|
|
}
|
|
|
|
ctx.Status(204)
|
|
}
|