api: EditWiki implementation (#5860)

Co-authored-by: Joe Chen <jc@unknwon.io>
pull/6650/head
Pavel M 2021-11-10 08:29:27 +03:00 committed by GitHub
parent 8938855b40
commit de3161155b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -89,7 +89,7 @@ func dumpTable(db *gorm.DB, table interface{}, w io.Writer) error {
return errors.Wrap(err, "encode JSON")
}
}
return nil
return rows.Err()
}
func dumpLegacyTables(dirPath string, verbose bool) error {

View File

@ -355,6 +355,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}, reqRepoWriter())
m.Patch("/issue-tracker", reqRepoWriter(), bind(api.EditIssueTrackerOption{}), repo.IssueTracker)
m.Patch("/wiki", reqRepoWriter(), bind(api.EditWikiOption{}), repo.Wiki)
m.Post("/mirror-sync", reqRepoWriter(), repo.MirrorSync)
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
}, repoAssignment())

View File

@ -390,6 +390,32 @@ func IssueTracker(c *context.APIContext, form api.EditIssueTrackerOption) {
c.NoContent()
}
func Wiki(c *context.APIContext, form api.EditWikiOption) {
_, repo := parseOwnerAndRepo(c)
if c.Written() {
return
}
if form.AllowPublicWiki != nil {
repo.AllowPublicWiki = *form.AllowPublicWiki
}
if form.EnableExternalWiki != nil {
repo.EnableExternalWiki = *form.EnableExternalWiki
}
if form.EnableWiki != nil {
repo.EnableWiki = *form.EnableWiki
}
if form.ExternalWikiURL != nil {
repo.ExternalWikiURL = *form.ExternalWikiURL
}
if err := db.UpdateRepository(repo, false); err != nil {
c.Error(err, "update repository")
return
}
c.NoContent()
}
func MirrorSync(c *context.APIContext) {
_, repo := parseOwnerAndRepo(c)
if c.Written() {