mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-11 06:24:04 +00:00
api: make updating name optional in repo edit
and path escape the new name param
This commit is contained in:
+12
-7
@@ -176,7 +176,7 @@ func apiReposCreate(c *gin.Context) {
|
|||||||
|
|
||||||
type reposEditParams struct {
|
type reposEditParams struct {
|
||||||
// Name of repository to modify
|
// Name of repository to modify
|
||||||
Name *string `binding:"required" json:"Name" example:"repo1"`
|
Name *string ` json:"Name" example:"new-repo-name"`
|
||||||
// Change Comment of repository
|
// Change Comment of repository
|
||||||
Comment *string ` json:"Comment" example:"example repo"`
|
Comment *string ` json:"Comment" example:"example repo"`
|
||||||
// Change Default Distribution for publishing
|
// Change Default Distribution for publishing
|
||||||
@@ -188,7 +188,7 @@ type reposEditParams struct {
|
|||||||
// @Summary Update Repository
|
// @Summary Update Repository
|
||||||
// @Description **Update local repository meta information**
|
// @Description **Update local repository meta information**
|
||||||
// @Tags Repos
|
// @Tags Repos
|
||||||
// @Param name path string true "Repository name"
|
// @Param name path string true "Repository name to modify"
|
||||||
// @Consume json
|
// @Consume json
|
||||||
// @Param request body reposEditParams true "Parameters"
|
// @Param request body reposEditParams true "Parameters"
|
||||||
// @Produce json
|
// @Produce json
|
||||||
@@ -201,15 +201,20 @@ func apiReposEdit(c *gin.Context) {
|
|||||||
if c.Bind(&b) != nil {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if b.Name != nil {
|
||||||
|
new_name, err := url.PathUnescape(*b.Name)
|
||||||
|
if err != nil {
|
||||||
|
AbortWithJSONError(c, 400, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*b.Name = new_name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
collectionFactory := context.NewCollectionFactory()
|
collectionFactory := context.NewCollectionFactory()
|
||||||
collection := collectionFactory.LocalRepoCollection()
|
collection := collectionFactory.LocalRepoCollection()
|
||||||
|
|
||||||
name, err := url.PathUnescape(c.Params.ByName("name"))
|
name := c.Params.ByName("name") // repo to modify
|
||||||
if err != nil {
|
|
||||||
AbortWithJSONError(c, 400, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
repo, err := collection.ByName(name)
|
repo, err := collection.ByName(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
AbortWithJSONError(c, 404, err)
|
AbortWithJSONError(c, 404, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user