mirror of
https://gitea.com/gitea/tea.git
synced 2024-11-03 04:27:21 -05:00
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:
parent
16ba594a28
commit
dda94a5dea
@ -54,10 +54,6 @@ func runReleaseDelete(cmd *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if release == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = client.DeleteRelease(ctx.Owner, ctx.Repo, release.ID)
|
_, err = client.DeleteRelease(ctx.Owner, ctx.Repo, release.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -72,10 +72,6 @@ func runReleaseEdit(cmd *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if release == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var isDraft, isPre *bool
|
var isDraft, isPre *bool
|
||||||
if ctx.IsSet("draft") {
|
if ctx.IsSet("draft") {
|
||||||
isDraft = gitea.OptionalBool(strings.ToLower(ctx.String("draft"))[:1] == "t")
|
isDraft = gitea.OptionalBool(strings.ToLower(ctx.String("draft"))[:1] == "t")
|
||||||
|
@ -50,14 +50,12 @@ func getReleaseByTag(owner, repo, tag string, client *gitea.Client) (*gitea.Rele
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(rl) == 0 {
|
if len(rl) == 0 {
|
||||||
fmt.Println("Repo does not have any release")
|
return nil, fmt.Errorf("Repo does not have any release")
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
for _, r := range rl {
|
for _, r := range rl {
|
||||||
if r.TagName == tag {
|
if r.TagName == tag {
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("Release tag does not exist")
|
return nil, fmt.Errorf("Release tag does not exist")
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user