Refactor errorhandling in getReleaseByTag() (#477)

small refactor for consistency

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/477
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin 2022-03-25 21:41:08 +08:00 committed by 6543
parent 16ba594a28
commit dda94a5dea
3 changed files with 2 additions and 12 deletions

View File

@ -54,10 +54,6 @@ func runReleaseDelete(cmd *cli.Context) error {
if err != nil {
return err
}
if release == nil {
return nil
}
_, err = client.DeleteRelease(ctx.Owner, ctx.Repo, release.ID)
if err != nil {
return err

View File

@ -72,10 +72,6 @@ func runReleaseEdit(cmd *cli.Context) error {
if err != nil {
return err
}
if release == nil {
return nil
}
var isDraft, isPre *bool
if ctx.IsSet("draft") {
isDraft = gitea.OptionalBool(strings.ToLower(ctx.String("draft"))[:1] == "t")

View File

@ -50,14 +50,12 @@ func getReleaseByTag(owner, repo, tag string, client *gitea.Client) (*gitea.Rele
return nil, err
}
if len(rl) == 0 {
fmt.Println("Repo does not have any release")
return nil, nil
return nil, fmt.Errorf("Repo does not have any release")
}
for _, r := range rl {
if r.TagName == tag {
return r, nil
}
}
fmt.Println("Release tag does not exist")
return nil, nil
return nil, fmt.Errorf("Release tag does not exist")
}