Skip to content

Commit b84303e

Browse files
GiteaBotlng2020
andauthored
Fix 500 when pushing release to an empty repo (#29554) (#29564)
Backport #29554 by @lng2020 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 Co-authored-by: Nanguan Lin <[email protected]>
1 parent 2b059f4 commit b84303e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

routers/api/v1/repo/release.go

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package repo
55

66
import (
7+
"fmt"
78
"net/http"
89

910
"code.gitea.io/gitea/models"
@@ -221,6 +222,10 @@ func CreateRelease(ctx *context.APIContext) {
221222
// "409":
222223
// "$ref": "#/responses/error"
223224
form := web.GetForm(ctx).(*api.CreateReleaseOption)
225+
if ctx.Repo.Repository.IsEmpty {
226+
ctx.Error(http.StatusUnprocessableEntity, "RepoIsEmpty", fmt.Errorf("repo is empty"))
227+
return
228+
}
224229
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, form.TagName)
225230
if err != nil {
226231
if !repo_model.IsErrReleaseNotExist(err) {

0 commit comments

Comments
 (0)