mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 18:08:30 +02:00
Refactor error handling (#308)
use fmt instead of log log.Fatal -> return err set non-zero exit code on error print to default err log cleanup fix vet Co-authored-by: Norwin Roosen <git@nroo.de> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/308 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:
15
cmd/open.go
15
cmd/open.go
@ -5,7 +5,6 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"log"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -42,12 +41,11 @@ func runOpen(cmd *cli.Context) error {
|
||||
case strings.EqualFold(number, "commits"):
|
||||
repo, err := local_git.RepoForWorkdir()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return err
|
||||
}
|
||||
b, err := repo.Head()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
name := b.Name()
|
||||
switch {
|
||||
@ -74,11 +72,6 @@ func runOpen(cmd *cli.Context) error {
|
||||
suffix = number
|
||||
}
|
||||
|
||||
u := path.Join(ctx.Login.URL, ctx.RepoSlug, suffix)
|
||||
err := open.Run(u)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
u := path.Join(ctx.Login.URL, ctx.Owner, ctx.Repo, suffix)
|
||||
return open.Run(u)
|
||||
}
|
||||
|
Reference in New Issue
Block a user