diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-09-08 12:51:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 04:51:15 +0000 |
commit | 4f32abaf941ba30ade1f96930a05d14f1c6a6782 (patch) | |
tree | 9351b7d654b20db032867041b0292924ec93bb3f /routers/api/v1/repo | |
parent | 3c0c27965836328abd2668dcd77710ee2460535e (diff) | |
download | gitea-4f32abaf941ba30ade1f96930a05d14f1c6a6782.tar.gz gitea-4f32abaf941ba30ade1f96930a05d14f1c6a6782.zip |
move repository deletion to service layer (#26948)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r-- | routers/api/v1/repo/migrate.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/teams.go | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go index 41374831de..4ddd452372 100644 --- a/routers/api/v1/repo/migrate.go +++ b/routers/api/v1/repo/migrate.go @@ -170,7 +170,7 @@ func Migrate(ctx *context.APIContext) { opts.Releases = false } - repo, err := repo_service.CreateRepositoryDirectly(ctx.Doer, repoOwner, repo_service.CreateRepoOptions{ + repo, err := repo_service.CreateRepositoryDirectly(ctx, ctx.Doer, repoOwner, repo_service.CreateRepoOptions{ Name: opts.RepoName, Description: opts.Description, OriginalURL: form.CloneAddr, @@ -200,7 +200,7 @@ func Migrate(ctx *context.APIContext) { } if repo != nil { - if errDelete := models.DeleteRepository(ctx.Doer, repoOwner.ID, repo.ID); errDelete != nil { + if errDelete := repo_service.DeleteRepositoryDirectly(ctx, ctx.Doer, repoOwner.ID, repo.ID); errDelete != nil { log.Error("DeleteRepository: %v", errDelete) } } diff --git a/routers/api/v1/repo/teams.go b/routers/api/v1/repo/teams.go index 01292f18d8..d1be619cac 100644 --- a/routers/api/v1/repo/teams.go +++ b/routers/api/v1/repo/teams.go @@ -7,11 +7,11 @@ import ( "fmt" "net/http" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/services/convert" org_service "code.gitea.io/gitea/services/org" + repo_service "code.gitea.io/gitea/services/repository" ) // ListTeams list a repository's teams @@ -97,7 +97,7 @@ func IsTeam(ctx *context.APIContext) { return } - if models.HasRepository(team, ctx.Repo.Repository.ID) { + if repo_service.HasRepository(team, ctx.Repo.Repository.ID) { apiTeam, err := convert.ToTeam(ctx, team) if err != nil { ctx.InternalServerError(err) @@ -192,7 +192,7 @@ func changeRepoTeam(ctx *context.APIContext, add bool) { return } - repoHasTeam := models.HasRepository(team, ctx.Repo.Repository.ID) + repoHasTeam := repo_service.HasRepository(team, ctx.Repo.Repository.ID) var err error if add { if repoHasTeam { @@ -205,7 +205,7 @@ func changeRepoTeam(ctx *context.APIContext, add bool) { ctx.Error(http.StatusUnprocessableEntity, "notAdded", fmt.Errorf("team '%s' was not added to repo", team.Name)) return } - err = models.RemoveRepository(team, ctx.Repo.Repository.ID) + err = repo_service.RemoveRepositoryFromTeam(ctx, team, ctx.Repo.Repository.ID) } if err != nil { ctx.InternalServerError(err) |