|
|
@ -5,7 +5,6 @@ |
|
|
|
package repo |
|
|
|
package repo |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
|
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/models" |
|
|
@ -14,9 +13,9 @@ import ( |
|
|
|
releaseservice "code.gitea.io/gitea/services/release" |
|
|
|
releaseservice "code.gitea.io/gitea/services/release" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// GetReleaseTag get a single release of a repository by its tagname
|
|
|
|
// GetReleaseByTag get a single release of a repository by tag name
|
|
|
|
func GetReleaseTag(ctx *context.APIContext) { |
|
|
|
func GetReleaseByTag(ctx *context.APIContext) { |
|
|
|
// swagger:operation GET /repos/{owner}/{repo}/releases/tags/{tag} repository repoGetReleaseTag
|
|
|
|
// swagger:operation GET /repos/{owner}/{repo}/releases/tags/{tag} repository repoGetReleaseByTag
|
|
|
|
// ---
|
|
|
|
// ---
|
|
|
|
// summary: Get a release by tag name
|
|
|
|
// summary: Get a release by tag name
|
|
|
|
// produces:
|
|
|
|
// produces:
|
|
|
@ -34,7 +33,7 @@ func GetReleaseTag(ctx *context.APIContext) { |
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// - name: tag
|
|
|
|
// - name: tag
|
|
|
|
// in: path
|
|
|
|
// in: path
|
|
|
|
// description: tagname of the release to get
|
|
|
|
// description: tag name of the release to get
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
@ -67,11 +66,11 @@ func GetReleaseTag(ctx *context.APIContext) { |
|
|
|
ctx.JSON(http.StatusOK, convert.ToRelease(release)) |
|
|
|
ctx.JSON(http.StatusOK, convert.ToRelease(release)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// DeleteReleaseTag delete a tag from a repository
|
|
|
|
// DeleteReleaseByTag delete a release from a repository by tag name
|
|
|
|
func DeleteReleaseTag(ctx *context.APIContext) { |
|
|
|
func DeleteReleaseByTag(ctx *context.APIContext) { |
|
|
|
// swagger:operation DELETE /repos/{owner}/{repo}/releases/tags/{tag} repository repoDeleteReleaseTag
|
|
|
|
// swagger:operation DELETE /repos/{owner}/{repo}/releases/tags/{tag} repository repoDeleteReleaseByTag
|
|
|
|
// ---
|
|
|
|
// ---
|
|
|
|
// summary: Delete a release tag
|
|
|
|
// summary: Delete a release by tag name
|
|
|
|
// parameters:
|
|
|
|
// parameters:
|
|
|
|
// - name: owner
|
|
|
|
// - name: owner
|
|
|
|
// in: path
|
|
|
|
// in: path
|
|
|
@ -85,7 +84,7 @@ func DeleteReleaseTag(ctx *context.APIContext) { |
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// - name: tag
|
|
|
|
// - name: tag
|
|
|
|
// in: path
|
|
|
|
// in: path
|
|
|
|
// description: name of the tag to delete
|
|
|
|
// description: tag name of the release to delete
|
|
|
|
// type: string
|
|
|
|
// type: string
|
|
|
|
// required: true
|
|
|
|
// required: true
|
|
|
|
// responses:
|
|
|
|
// responses:
|
|
|
@ -93,27 +92,25 @@ func DeleteReleaseTag(ctx *context.APIContext) { |
|
|
|
// "$ref": "#/responses/empty"
|
|
|
|
// "$ref": "#/responses/empty"
|
|
|
|
// "404":
|
|
|
|
// "404":
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
// "409":
|
|
|
|
|
|
|
|
// "$ref": "#/responses/conflict"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tag := ctx.Params(":tag") |
|
|
|
tag := ctx.Params(":tag") |
|
|
|
|
|
|
|
|
|
|
|
release, err := models.GetRelease(ctx.Repo.Repository.ID, tag) |
|
|
|
release, err := models.GetRelease(ctx.Repo.Repository.ID, tag) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if models.IsErrReleaseNotExist(err) { |
|
|
|
if models.IsErrReleaseNotExist(err) { |
|
|
|
ctx.Error(http.StatusNotFound, "GetRelease", err) |
|
|
|
ctx.NotFound() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetRelease", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetRelease", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !release.IsTag { |
|
|
|
if release.IsTag { |
|
|
|
ctx.Error(http.StatusConflict, "IsTag", errors.New("a tag attached to a release cannot be deleted directly")) |
|
|
|
ctx.NotFound() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := releaseservice.DeleteReleaseByID(release.ID, ctx.User, true); err != nil { |
|
|
|
if err = releaseservice.DeleteReleaseByID(release.ID, ctx.User, false); err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|