Merge pull request #465 from SHyx0rmZ/allow-empty-repo-edits-in-api

Allow comment and defaults to be empty when editing a repo through the API
This commit is contained in:
Andrey Smirnov
2016-12-08 18:26:45 +03:00
committed by GitHub
+9 -9
View File
@@ -60,9 +60,9 @@ func apiReposCreate(c *gin.Context) {
// PUT /api/repos/:name // PUT /api/repos/:name
func apiReposEdit(c *gin.Context) { func apiReposEdit(c *gin.Context) {
var b struct { var b struct {
Comment string Comment *string
DefaultDistribution string DefaultDistribution *string
DefaultComponent string DefaultComponent *string
} }
if !c.Bind(&b) { if !c.Bind(&b) {
@@ -79,14 +79,14 @@ func apiReposEdit(c *gin.Context) {
return return
} }
if b.Comment != "" { if b.Comment != nil {
repo.Comment = b.Comment repo.Comment = *b.Comment
} }
if b.DefaultDistribution != "" { if b.DefaultDistribution != nil {
repo.DefaultDistribution = b.DefaultDistribution repo.DefaultDistribution = *b.DefaultDistribution
} }
if b.DefaultComponent != "" { if b.DefaultComponent != nil {
repo.DefaultComponent = b.DefaultComponent repo.DefaultComponent = *b.DefaultComponent
} }
err = collection.Update(repo) err = collection.Update(repo)