mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 10:20:39 +00:00
[API] GetRelease by tag only return release (#14397)
get release by tag should filter out tag releases to be consistent with list releases and get by id Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
87009ab40a
commit
3c965c3e30
2 changed files with 8 additions and 4 deletions
|
@ -7,7 +7,6 @@ package integrations
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
|
@ -152,7 +151,7 @@ func TestAPIGetReleaseByTag(t *testing.T) {
|
||||||
|
|
||||||
var err *api.APIError
|
var err *api.APIError
|
||||||
DecodeJSON(t, resp, &err)
|
DecodeJSON(t, resp, &err)
|
||||||
assert.True(t, strings.HasPrefix(err.Message, "release tag does not exist"))
|
assert.EqualValues(t, "Not Found", err.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPIDeleteTagByName(t *testing.T) {
|
func TestAPIDeleteTagByName(t *testing.T) {
|
||||||
|
|
|
@ -48,14 +48,19 @@ func GetReleaseTag(ctx *context.APIContext) {
|
||||||
release, err := models.GetRelease(ctx.Repo.Repository.ID, tag)
|
release, err := models.GetRelease(ctx.Repo.Repository.ID, tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrReleaseNotExist(err) {
|
if models.IsErrReleaseNotExist(err) {
|
||||||
ctx.Error(http.StatusNotFound, "GetRelease", err)
|
ctx.NotFound()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Error(http.StatusInternalServerError, "GetRelease", err)
|
ctx.Error(http.StatusInternalServerError, "GetRelease", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := release.LoadAttributes(); err != nil {
|
if release.IsTag {
|
||||||
|
ctx.NotFound()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = release.LoadAttributes(); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue