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

View File

@@ -60,9 +60,9 @@ func apiReposCreate(c *gin.Context) {
// PUT /api/repos/:name
func apiReposEdit(c *gin.Context) {
var b struct {
Comment string
DefaultDistribution string
DefaultComponent string
Comment *string
DefaultDistribution *string
DefaultComponent *string
}
if !c.Bind(&b) {
@@ -79,14 +79,14 @@ func apiReposEdit(c *gin.Context) {
return
}
if b.Comment != "" {
repo.Comment = b.Comment
if b.Comment != nil {
repo.Comment = *b.Comment
}
if b.DefaultDistribution != "" {
repo.DefaultDistribution = b.DefaultDistribution
if b.DefaultDistribution != nil {
repo.DefaultDistribution = *b.DefaultDistribution
}
if b.DefaultComponent != "" {
repo.DefaultComponent = b.DefaultComponent
if b.DefaultComponent != nil {
repo.DefaultComponent = *b.DefaultComponent
}
err = collection.Update(repo)