|
|
@ -15,7 +15,7 @@ import ( |
|
|
|
api "code.gitea.io/gitea/modules/structs" |
|
|
|
api "code.gitea.io/gitea/modules/structs" |
|
|
|
"code.gitea.io/gitea/modules/web" |
|
|
|
"code.gitea.io/gitea/modules/web" |
|
|
|
"code.gitea.io/gitea/routers/api/v1/utils" |
|
|
|
"code.gitea.io/gitea/routers/api/v1/utils" |
|
|
|
releaseservice "code.gitea.io/gitea/services/release" |
|
|
|
release_service "code.gitea.io/gitea/services/release" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// GetRelease get a single release of a repository
|
|
|
|
// GetRelease get a single release of a repository
|
|
|
@ -49,7 +49,7 @@ func GetRelease(ctx *context.APIContext) { |
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
|
|
|
|
|
|
|
|
id := ctx.ParamsInt64(":id") |
|
|
|
id := ctx.ParamsInt64(":id") |
|
|
|
release, err := models.GetReleaseByID(id) |
|
|
|
release, err := models.GetReleaseByID(ctx, id) |
|
|
|
if err != nil && !models.IsErrReleaseNotExist(err) { |
|
|
|
if err != nil && !models.IsErrReleaseNotExist(err) { |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -202,7 +202,7 @@ func CreateRelease(ctx *context.APIContext) { |
|
|
|
IsTag: false, |
|
|
|
IsTag: false, |
|
|
|
Repo: ctx.Repo.Repository, |
|
|
|
Repo: ctx.Repo.Repository, |
|
|
|
} |
|
|
|
} |
|
|
|
if err := releaseservice.CreateRelease(ctx.Repo.GitRepo, rel, nil, ""); err != nil { |
|
|
|
if err := release_service.CreateRelease(ctx.Repo.GitRepo, rel, nil, ""); err != nil { |
|
|
|
if models.IsErrReleaseAlreadyExist(err) { |
|
|
|
if models.IsErrReleaseAlreadyExist(err) { |
|
|
|
ctx.Error(http.StatusConflict, "ReleaseAlreadyExist", err) |
|
|
|
ctx.Error(http.StatusConflict, "ReleaseAlreadyExist", err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -225,7 +225,7 @@ func CreateRelease(ctx *context.APIContext) { |
|
|
|
rel.Repo = ctx.Repo.Repository |
|
|
|
rel.Repo = ctx.Repo.Repository |
|
|
|
rel.Publisher = ctx.Doer |
|
|
|
rel.Publisher = ctx.Doer |
|
|
|
|
|
|
|
|
|
|
|
if err = releaseservice.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil { |
|
|
|
if err = release_service.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -271,7 +271,7 @@ func EditRelease(ctx *context.APIContext) { |
|
|
|
|
|
|
|
|
|
|
|
form := web.GetForm(ctx).(*api.EditReleaseOption) |
|
|
|
form := web.GetForm(ctx).(*api.EditReleaseOption) |
|
|
|
id := ctx.ParamsInt64(":id") |
|
|
|
id := ctx.ParamsInt64(":id") |
|
|
|
rel, err := models.GetReleaseByID(id) |
|
|
|
rel, err := models.GetReleaseByID(ctx, id) |
|
|
|
if err != nil && !models.IsErrReleaseNotExist(err) { |
|
|
|
if err != nil && !models.IsErrReleaseNotExist(err) { |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -300,12 +300,13 @@ func EditRelease(ctx *context.APIContext) { |
|
|
|
if form.IsPrerelease != nil { |
|
|
|
if form.IsPrerelease != nil { |
|
|
|
rel.IsPrerelease = *form.IsPrerelease |
|
|
|
rel.IsPrerelease = *form.IsPrerelease |
|
|
|
} |
|
|
|
} |
|
|
|
if err := releaseservice.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil { |
|
|
|
if err := release_service.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rel, err = models.GetReleaseByID(id) |
|
|
|
// reload data from database
|
|
|
|
|
|
|
|
rel, err = models.GetReleaseByID(ctx, id) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -346,7 +347,7 @@ func DeleteRelease(ctx *context.APIContext) { |
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
// "$ref": "#/responses/notFound"
|
|
|
|
|
|
|
|
|
|
|
|
id := ctx.ParamsInt64(":id") |
|
|
|
id := ctx.ParamsInt64(":id") |
|
|
|
rel, err := models.GetReleaseByID(id) |
|
|
|
rel, err := models.GetReleaseByID(ctx, id) |
|
|
|
if err != nil && !models.IsErrReleaseNotExist(err) { |
|
|
|
if err != nil && !models.IsErrReleaseNotExist(err) { |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -356,7 +357,7 @@ func DeleteRelease(ctx *context.APIContext) { |
|
|
|
ctx.NotFound() |
|
|
|
ctx.NotFound() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if err := releaseservice.DeleteReleaseByID(ctx, id, ctx.Doer, false); err != nil { |
|
|
|
if err := release_service.DeleteReleaseByID(ctx, id, ctx.Doer, false); err != nil { |
|
|
|
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err) |
|
|
|
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|