Переглянути джерело

Add repo mirror sync API endpoint (#1508)

* API: Add repo mirror sync

* Correct error message

* Change http status to 200
tags/v1.2.0-rc1
Jonas 7 роки тому
джерело
коміт
f995bcc87a
2 змінених файлів з 13 додано та 0 видалено
  1. 1
    0
      routers/api/v1/api.go
  2. 12
    0
      routers/api/v1/repo/repo.go

+ 1
- 0
routers/api/v1/api.go Переглянути файл

Patch(bind(api.EditReleaseOption{}), repo.EditRelease). Patch(bind(api.EditReleaseOption{}), repo.EditRelease).
Delete(repo.DeleteRelease) Delete(repo.DeleteRelease)
}) })
m.Post("/mirror-sync", repo.MirrorSync)
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig) m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
m.Group("/pulls", func() { m.Group("/pulls", func() {
m.Combo("").Get(bind(api.ListPullRequestsOptions{}), repo.ListPullRequests).Post(reqRepoWriter(), bind(api.CreatePullRequestOption{}), repo.CreatePullRequest) m.Combo("").Get(bind(api.ListPullRequestsOptions{}), repo.ListPullRequests).Post(reqRepoWriter(), bind(api.CreatePullRequestOption{}), repo.CreatePullRequest)

+ 12
- 0
routers/api/v1/repo/repo.go Переглянути файл

log.Trace("Repository deleted: %s/%s", owner.Name, repo.Name) log.Trace("Repository deleted: %s/%s", owner.Name, repo.Name)
ctx.Status(204) 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)
}

Завантаження…
Відмінити
Зберегти