Make comment and defaults nullable in repo edit

This commit is contained in:
Patrick Pokatilo
2016-12-08 15:45:19 +01:00
parent fb27fb01ea
commit 1c6b174b8a

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,9 +79,15 @@ func apiReposEdit(c *gin.Context) {
return
}
repo.Comment = b.Comment
repo.DefaultDistribution = b.DefaultDistribution
repo.DefaultComponent = b.DefaultComponent
if b.Comment != nil {
repo.Comment = *b.Comment
}
if b.DefaultDistribution != nil {
repo.DefaultDistribution = *b.DefaultDistribution
}
if b.DefaultComponent != nil {
repo.DefaultComponent = *b.DefaultComponent
}
err = collection.Update(repo)
if err != nil {