diff options
author | Jonas <cez81@users.noreply.github.com> | 2017-04-19 13:09:49 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-04-19 19:09:49 +0800 |
commit | f995bcc87a9e693883292247ec985df7541d06bf (patch) | |
tree | 8c79f03907977b80f373648419abb11226af6280 /routers | |
parent | 2eeae84cbd80544157a82c7f031489eaaceaa873 (diff) | |
download | gitea-f995bcc87a9e693883292247ec985df7541d06bf.tar.gz gitea-f995bcc87a9e693883292247ec985df7541d06bf.zip |
Add repo mirror sync API endpoint (#1508)
* API: Add repo mirror sync
* Correct error message
* Change http status to 200
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/api.go | 1 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 2a1f5e196c..74aa995c97 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -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) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 317b0c57a1..0f22eaeb8f 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -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) +} |