aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-12-17 19:44:16 -0800
committerGitHub <noreply@github.com>2024-12-18 11:44:16 +0800
commite4c4629465f4e45ffdb9ef5eff6ef17e15ee4c2d (patch)
tree14ac77bb922dfdb9883630f6b2769973becb6f7e /routers/api/v1
parentb9457422934f33a37e0285d100007aae12e87ff7 (diff)
downloadgitea-e4c4629465f4e45ffdb9ef5eff6ef17e15ee4c2d.tar.gz
gitea-e4c4629465f4e45ffdb9ef5eff6ef17e15ee4c2d.zip
Move RepoTransfer from models to models/repo sub package (#32506)
`RepoTransfer` now is at models, but if we want to move it into `repo` model, it will depend on `Team`. So this PR also makes repo model depend on org model to make it possible. Just refactor, no code change. - [x] Move `DeleteOrganization` from `models/organization` to service layer - [x] Move `AccessibleTeamReposEnv` to `models/repo` - [x] Move `RepoTransfer` from `models` to `models/repo` - [x] Merge `getUserTeamIDs` and `GetUserTeamIDs`, Merge `GetUserTeams` and `getUserTeams`. - [x] Remove `Team`'s `Repos []*repo_model.Repository` to avoid dependency recycle.
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/org/team.go6
-rw-r--r--routers/api/v1/repo/teams.go2
-rw-r--r--routers/api/v1/repo/transfer.go7
3 files changed, 7 insertions, 8 deletions
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index bc50960b61..8164d2cfe9 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -573,19 +573,19 @@ func GetTeamRepos(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
team := ctx.Org.Team
- teamRepos, err := organization.GetTeamRepositories(ctx, &organization.SearchTeamRepoOptions{
+ teamRepos, err := repo_model.GetTeamRepositories(ctx, &repo_model.SearchTeamRepoOptions{
ListOptions: utils.GetListOptions(ctx),
TeamID: team.ID,
})
if err != nil {
- ctx.Error(http.StatusInternalServerError, "GetTeamRepos", err)
+ ctx.Error(http.StatusInternalServerError, "GetTeamRepositories", err)
return
}
repos := make([]*api.Repository, len(teamRepos))
for i, repo := range teamRepos {
permission, err := access_model.GetUserRepoPermission(ctx, repo, ctx.Doer)
if err != nil {
- ctx.Error(http.StatusInternalServerError, "GetTeamRepos", err)
+ ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err)
return
}
repos[i] = convert.ToRepo(ctx, repo, permission)
diff --git a/routers/api/v1/repo/teams.go b/routers/api/v1/repo/teams.go
index 82ecaf3020..42fb0a1d75 100644
--- a/routers/api/v1/repo/teams.go
+++ b/routers/api/v1/repo/teams.go
@@ -42,7 +42,7 @@ func ListTeams(ctx *context.APIContext) {
return
}
- teams, err := organization.GetRepoTeams(ctx, ctx.Repo.Repository)
+ teams, err := organization.GetRepoTeams(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.ID)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/repo/transfer.go b/routers/api/v1/repo/transfer.go
index 776b336761..787ec34404 100644
--- a/routers/api/v1/repo/transfer.go
+++ b/routers/api/v1/repo/transfer.go
@@ -8,7 +8,6 @@ import (
"fmt"
"net/http"
- "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/perm"
access_model "code.gitea.io/gitea/models/perm/access"
@@ -108,7 +107,7 @@ func Transfer(ctx *context.APIContext) {
oldFullname := ctx.Repo.Repository.FullName()
if err := repo_service.StartRepositoryTransfer(ctx, ctx.Doer, newOwner, ctx.Repo.Repository, teams); err != nil {
- if models.IsErrRepoTransferInProgress(err) {
+ if repo_model.IsErrRepoTransferInProgress(err) {
ctx.Error(http.StatusConflict, "StartRepositoryTransfer", err)
return
}
@@ -213,9 +212,9 @@ func RejectTransfer(ctx *context.APIContext) {
}
func acceptOrRejectRepoTransfer(ctx *context.APIContext, accept bool) error {
- repoTransfer, err := models.GetPendingRepositoryTransfer(ctx, ctx.Repo.Repository)
+ repoTransfer, err := repo_model.GetPendingRepositoryTransfer(ctx, ctx.Repo.Repository)
if err != nil {
- if models.IsErrNoPendingTransfer(err) {
+ if repo_model.IsErrNoPendingTransfer(err) {
ctx.NotFound()
return nil
}