From d13de0464e1e5faa368b41e639ba57130c632bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Sat, 26 Sep 2020 14:06:41 +0000 Subject: [PATCH] api: allow renaming repos --- api/repos.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/repos.go b/api/repos.go index b0792f49..1c007449 100644 --- a/api/repos.go +++ b/api/repos.go @@ -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 }