mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +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:
parent
d2d5910894
commit
9e85358777
10 changed files with 179 additions and 89 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue