mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-28 14:43:52 +03: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)
(cherry picked from commit 6e2aafd5130cb9436f02209ae90bf79a58cc13ae)
This commit is contained in:
parent
006d4ce6f2
commit
c69a0bb506
1 changed files with 5 additions and 0 deletions
|
@ -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"
|
||||||
|
@ -215,6 +216,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 a new issue