mirror of
https://github.com/go-gitea/gitea
synced 2024-11-17 07:34:25 +00:00
Backport #29554 by @lng2020
As title.
The former code directly used `ctx.Repo.GitRepo`, causing 500.
22b4f0c09f/routers/api/v1/repo/release.go (L241)
Co-authored-by: Nanguan Lin <nanguanlin6@gmail.com>
This commit is contained in:
parent
2b059f493e
commit
b84303ef6e
@ -4,6 +4,7 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
@ -221,6 +222,10 @@ func CreateRelease(ctx *context.APIContext) {
|
|||||||
// "409":
|
// "409":
|
||||||
// "$ref": "#/responses/error"
|
// "$ref": "#/responses/error"
|
||||||
form := web.GetForm(ctx).(*api.CreateReleaseOption)
|
form := web.GetForm(ctx).(*api.CreateReleaseOption)
|
||||||
|
if ctx.Repo.Repository.IsEmpty {
|
||||||
|
ctx.Error(http.StatusUnprocessableEntity, "RepoIsEmpty", fmt.Errorf("repo is empty"))
|
||||||
|
return
|
||||||
|
}
|
||||||
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, form.TagName)
|
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, form.TagName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !repo_model.IsErrReleaseNotExist(err) {
|
if !repo_model.IsErrReleaseNotExist(err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user