aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorNanguan Lin <nanguanlin6@gmail.com>2024-03-04 00:49:05 +0800
committerGitHub <noreply@github.com>2024-03-03 16:49:05 +0000
commit6e2aafd5130cb9436f02209ae90bf79a58cc13ae (patch)
tree992f1cdd364d434a3a0e9e28f2802d3985b8a89c /routers
parentefa631aeead094267d46ea8f86e6d568f0c731e4 (diff)
downloadgitea-6e2aafd5130cb9436f02209ae90bf79a58cc13ae.tar.gz
gitea-6e2aafd5130cb9436f02209ae90bf79a58cc13ae.zip
Fix 500 when pushing release to an empty repo (#29554)
As title. The former code directly used `ctx.Repo.GitRepo`, causing 500. https://github.com/go-gitea/gitea/blob/22b4f0c09f1de5e581929bd10f39833d30d2c482/routers/api/v1/repo/release.go#L241
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/release.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go
index a47fc1cc59..f0f3c0bbc7 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -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) {