mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor api repo dir (#10048)
* mv migrate * mv mirror Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
48
routers/api/v1/repo/mirror.go
Normal file
48
routers/api/v1/repo/mirror.go
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
mirror_service "code.gitea.io/gitea/services/mirror"
|
||||
)
|
||||
|
||||
// MirrorSync adds a mirrored repository to the sync queue
|
||||
func MirrorSync(ctx *context.APIContext) {
|
||||
// swagger:operation POST /repos/{owner}/{repo}/mirror-sync repository repoMirrorSync
|
||||
// ---
|
||||
// summary: Sync a mirrored repository
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: owner
|
||||
// in: path
|
||||
// description: owner of the repo to sync
|
||||
// type: string
|
||||
// required: true
|
||||
// - name: repo
|
||||
// in: path
|
||||
// description: name of the repo to sync
|
||||
// type: string
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
|
||||
if !ctx.Repo.CanWrite(models.UnitTypeCode) {
|
||||
ctx.Error(http.StatusForbidden, "MirrorSync", "Must have write access")
|
||||
}
|
||||
|
||||
mirror_service.StartToMirror(repo.ID)
|
||||
|
||||
ctx.Status(http.StatusOK)
|
||||
}
|
Reference in New Issue
Block a user