Browse Source

api/repo: add endpoint to sync mirror (#2235)

pull/4343/head
Unknwon 8 years ago
parent
commit
c441f8080e
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 1
      routers/api/v1/api.go
  2. 13
      routers/api/v1/repo/repo.go

1
routers/api/v1/api.go

@ -308,6 +308,7 @@ func RegisterRoutes(m *macaron.Macaron) {
Patch(reqRepoWriter(), bind(api.EditMilestoneOption{}), repo.EditMilestone). Patch(reqRepoWriter(), bind(api.EditMilestoneOption{}), repo.EditMilestone).
Delete(reqRepoWriter(), repo.DeleteMilestone) Delete(reqRepoWriter(), repo.DeleteMilestone)
}) })
m.Post("/mirror-sync", repo.MirrorSync)
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig) m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
}, repoAssignment()) }, repoAssignment())
}, reqToken()) }, reqToken())

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

@ -359,3 +359,16 @@ func ListForks(ctx *context.APIContext) {
ctx.JSON(200, &apiForks) 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)
}

Loading…
Cancel
Save