mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
Move some repositories' operations to a standalone service package (#8557)
* Move some repositories' operations to a standalone service package * improve code * remove unused codes * add rollback when fork failed * add repo when return
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
)
|
||||
|
||||
// ListForks list a repository's forks
|
||||
@@ -97,10 +98,12 @@ func CreateFork(ctx *context.APIContext, form api.CreateForkOption) {
|
||||
}
|
||||
forker = org
|
||||
}
|
||||
fork, err := models.ForkRepository(ctx.User, forker, repo, repo.Name, repo.Description)
|
||||
|
||||
fork, err := repo_service.ForkRepository(ctx.User, forker, repo, repo.Name, repo.Description)
|
||||
if err != nil {
|
||||
ctx.Error(500, "ForkRepository", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(202, fork.APIFormat(models.AccessModeOwner))
|
||||
}
|
||||
|
Reference in New Issue
Block a user