fix(release): report an unknown target clearly, hint to push, and add --verify-tag (follow gh)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 19:01:19 +02:00
1 parent 9360f39cc8
commit c97044f76c
4 files changed
+142 -1

No files matched your search

+18
View File
@@ -5,9 +5,12 @@ package services
import (
"context"
"errors"
"fmt"
"io"
"net/http"
"strconv"
"strings"
gitea "gitea.dev/sdk"
"gitea.dev/tea/internal/transport"
@@ -103,9 +106,24 @@ func (s Releases) Create(ctx context.Context, opts ReleaseOptions) (Release, err
IsDraft: deref(opts.Draft), IsPrerelease: deref(opts.Prerelease),
})
})
if apiErr, ok := errors.AsType[*transport.APIError](err); ok && apiErr.Status == http.StatusNotFound && strings.Contains(apiErr.Message, "target") {
// The release does not exist yet, so a 404 here names the unresolvable target, not the release.
return item, &NotFoundError{Kind: "target", Key: strconv.Quote(deref(opts.Target)), Scope: s.Repository, Err: err}
}
return item, Classify(err, "release", deref(opts.Tag), s.Repository)
}
// TagExists reports whether the repository on the server has the tag.
func (s Releases) TagExists(ctx context.Context, tag string) (bool, error) {
_, err := repoCall(ctx, s.Client, s.Repository, func(ctx context.Context, c *gitea.Client, owner, repo string) (*gitea.Tag, *gitea.Response, error) {
return c.Repositories.GetTag(ctx, owner, repo, tag)
})
if IsNotFound(err) {
return false, nil
}
return err == nil, err
}
// Edit changes only supplied release fields; Gitea ignores empty text fields.
func (s Releases) Edit(ctx context.Context, id int64, opts ReleaseOptions) (Release, error) {
return repoConvert(ctx, s.Client, s.Repository, releaseFrom, func(ctx context.Context, c *gitea.Client, owner, repo string) (*gitea.Release, *gitea.Response, error) {