Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] GetRelease by tag only return release #14397

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions integrations/api_releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package integrations
import (
"fmt"
"net/http"
"strings"
"testing"

"code.gitea.io/gitea/models"
Expand Down Expand Up @@ -152,7 +151,7 @@ func TestAPIGetReleaseByTag(t *testing.T) {

var err *api.APIError
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) {
Expand Down
9 changes: 7 additions & 2 deletions routers/api/v1/repo/release_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ func GetReleaseTag(ctx *context.APIContext) {
release, err := models.GetRelease(ctx.Repo.Repository.ID, tag)
if err != nil {
if models.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusNotFound, "GetRelease", err)
ctx.NotFound()
return
}
ctx.Error(http.StatusInternalServerError, "GetRelease", err)
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)
return
}
Expand Down