0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-23 04:44:38 +01:00

Fix 500 when pushing release to an empty repo (#29554)

As title. 
The former code directly used `ctx.Repo.GitRepo`, causing 500.

22b4f0c09f/routers/api/v1/repo/release.go (L241)
This commit is contained in:
Nanguan Lin 2024-03-04 00:49:05 +08:00 committed by GitHub
parent efa631aeea
commit 6e2aafd513
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@
package repo
import (
"fmt"
"net/http"
"code.gitea.io/gitea/models"
@ -215,6 +216,10 @@ func CreateRelease(ctx *context.APIContext) {
// "409":
// "$ref": "#/responses/error"
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)
if err != nil {
if !repo_model.IsErrReleaseNotExist(err) {