You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mirror.go 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "net/http"
  7. "code.gitea.io/gitea/models"
  8. "code.gitea.io/gitea/modules/context"
  9. mirror_service "code.gitea.io/gitea/services/mirror"
  10. )
  11. // MirrorSync adds a mirrored repository to the sync queue
  12. func MirrorSync(ctx *context.APIContext) {
  13. // swagger:operation POST /repos/{owner}/{repo}/mirror-sync repository repoMirrorSync
  14. // ---
  15. // summary: Sync a mirrored repository
  16. // produces:
  17. // - application/json
  18. // parameters:
  19. // - name: owner
  20. // in: path
  21. // description: owner of the repo to sync
  22. // type: string
  23. // required: true
  24. // - name: repo
  25. // in: path
  26. // description: name of the repo to sync
  27. // type: string
  28. // required: true
  29. // responses:
  30. // "200":
  31. // "$ref": "#/responses/empty"
  32. // "403":
  33. // "$ref": "#/responses/forbidden"
  34. repo := ctx.Repo.Repository
  35. if !ctx.Repo.CanWrite(models.UnitTypeCode) {
  36. ctx.Error(http.StatusForbidden, "MirrorSync", "Must have write access")
  37. }
  38. mirror_service.StartToMirror(repo.ID)
  39. ctx.Status(http.StatusOK)
  40. }