Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-12-14 15:31:57 +01:00
forgejo/routers/api/v1/repo/sync_fork.go

55 lines
1.2 KiB
Go
Raw Normal View History

2024-02-19 14:11:26 +01:00
package repo
import (
"net/http"
"code.gitea.io/gitea/modules/context"
repo_service "code.gitea.io/gitea/services/repository"
)
// SyncForkBranch syncs a fork branch with the base branch
func SyncForkBranch(ctx *context.APIContext) {
// swagger:operation POST /repos/{owner}/{repo}/sync_fork/{branch} repository repoSyncForkBranch
// ---
// summary: Syncs a fork
// produces:
// - application/json
// parameters:
// - name: owner
// in: path
// description: owner of the repo
// type: string
// required: true
// - name: repo
// in: path
// description: name of the repo
// type: string
// required: true
// - name: branch
// in: path
// description: The branch
// type: string
// required: true
// responses:
// "400":
// "$ref": "#/responses/error"
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
if !ctx.Repo.Repository.IsFork {
ctx.Error(http.StatusBadRequest, "NoFork", "The Repo must be a fork")
return
}
branch := ctx.Params("branch")
err := repo_service.SyncFork(ctx, ctx.Doer, ctx.Repo.Repository, branch)
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)
return
}
ctx.Status(http.StatusNoContent)
}