aboutsummaryrefslogtreecommitdiff
path: root/routers/api/v1
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-03-23 20:46:39 -0400
committerUnknwon <u@gogs.io>2017-03-23 20:46:39 -0400
commitc441f8080e0095fde572abe390012feb681f56b1 (patch)
treea5e433487ff0134316f60996b0c86c2cdc59ae42 /routers/api/v1
parentbd1e7573505b9fe0adaa376c025c3e2e33ce4583 (diff)
api/repo: add endpoint to sync mirror (#2235)
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/api.go1
-rw-r--r--routers/api/v1/repo/repo.go13
2 files changed, 14 insertions, 0 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index ad235540..3e83c559 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -308,6 +308,7 @@ func RegisterRoutes(m *macaron.Macaron) {
Patch(reqRepoWriter(), bind(api.EditMilestoneOption{}), repo.EditMilestone).
Delete(reqRepoWriter(), repo.DeleteMilestone)
})
+ m.Post("/mirror-sync", repo.MirrorSync)
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
}, repoAssignment())
}, reqToken())
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 99ae391d..326ff25e 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -359,3 +359,16 @@ func ListForks(ctx *context.APIContext) {
ctx.JSON(200, &apiForks)
}
+
+func MirrorSync(ctx *context.APIContext) {
+ _, repo := parseOwnerAndRepo(ctx)
+ if ctx.Written() {
+ return
+ } else if !repo.IsMirror {
+ ctx.Status(404)
+ return
+ }
+
+ go models.MirrorQueue.Add(repo.ID)
+ ctx.Status(202)
+}