]> source.dussan.org Git - gitea.git/commitdiff
Add repo mirror sync API endpoint (#1508)
authorJonas <cez81@users.noreply.github.com>
Wed, 19 Apr 2017 11:09:49 +0000 (13:09 +0200)
committerLunny Xiao <xiaolunwen@gmail.com>
Wed, 19 Apr 2017 11:09:49 +0000 (19:09 +0800)
* API: Add repo mirror sync

* Correct error message

* Change http status to 200

routers/api/v1/api.go
routers/api/v1/repo/repo.go

index 2a1f5e196c974f33d27a0d6d012e0db62283077c..74aa995c973576c703fff79f2f9d2fed11f09678 100644 (file)
@@ -402,6 +402,7 @@ func RegisterRoutes(m *macaron.Macaron) {
                                                Patch(bind(api.EditReleaseOption{}), repo.EditRelease).
                                                Delete(repo.DeleteRelease)
                                })
+                               m.Post("/mirror-sync", repo.MirrorSync)
                                m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
                                m.Group("/pulls", func() {
                                        m.Combo("").Get(bind(api.ListPullRequestsOptions{}), repo.ListPullRequests).Post(reqRepoWriter(), bind(api.CreatePullRequestOption{}), repo.CreatePullRequest)
index 317b0c57a1029683afa02d3fbcf069d47e94e4a5..0f22eaeb8f77dfcf3ae5367f88ef8ab40ed1d193 100644 (file)
@@ -269,3 +269,15 @@ func Delete(ctx *context.APIContext) {
        log.Trace("Repository deleted: %s/%s", owner.Name, repo.Name)
        ctx.Status(204)
 }
+
+// MirrorSync adds a mirrored repository to the sync queue
+func MirrorSync(ctx *context.APIContext) {
+       repo := ctx.Repo.Repository
+
+       if !ctx.Repo.IsWriter() {
+               ctx.Error(403, "MirrorSync", "Must have write access")
+       }
+
+       go models.MirrorQueue.Add(repo.ID)
+       ctx.Status(200)
+}