api: allow renaming repos

This commit is contained in:
André Roth
2020-09-26 14:06:41 +00:00
committed by Lorenzo Bolla
parent c0528888f4
commit d13de0464e
+10
View File
@@ -61,6 +61,7 @@ func apiReposCreate(c *gin.Context) {
// PUT /api/repos/:name
func apiReposEdit(c *gin.Context) {
var b struct {
Name *string
Comment *string
DefaultDistribution *string
DefaultComponent *string
@@ -79,6 +80,15 @@ func apiReposEdit(c *gin.Context) {
return
}
if b.Name != nil {
_, err := collection.ByName(*b.Name)
if err == nil {
// already exists
c.AbortWithError(404, err)
return
}
repo.Name = *b.Name
}
if b.Comment != nil {
repo.Comment = *b.Comment
}