From edd180a8f5faa7393469ff5d3b25dd46c6f9778b Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Mon, 20 Jul 2020 03:09:34 +0000 Subject: [PATCH] Fix notification: --all dont relay on a repo (#159) fix nil pointer exeption make notifications work outside a repo Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/159 Reviewed-by: Lunny Xiao Reviewed-by: mrsdizzie --- cmd/config.go | 3 +++ cmd/notifications.go | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 89255e3..ca5517c 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -197,6 +197,9 @@ func curGitRepoPath(path string) (*Login, string, error) { } else { repo, err = git.RepoFromPath(path) } + if err != nil { + return nil, "", err + } gitConfig, err := repo.Config() if err != nil { return nil, "", err diff --git a/cmd/notifications.go b/cmd/notifications.go index 16ba479..cb4e002 100644 --- a/cmd/notifications.go +++ b/cmd/notifications.go @@ -46,9 +46,6 @@ var CmdNotifications = cli.Command{ } func runNotifications(ctx *cli.Context) error { - login, owner, repo := initCommand() - - client := login.Client() var news []*gitea.NotificationThread var err error @@ -58,11 +55,13 @@ func runNotifications(ctx *cli.Context) error { } if ctx.Bool("all") { - news, err = client.ListNotifications(gitea.ListNotificationOptions{ + login := initCommandLoginOnly() + news, err = login.Client().ListNotifications(gitea.ListNotificationOptions{ ListOptions: listOpts, }) } else { - news, err = client.ListRepoNotifications(owner, repo, gitea.ListNotificationOptions{ + login, owner, repo := initCommand() + news, err = login.Client().ListRepoNotifications(owner, repo, gitea.ListNotificationOptions{ ListOptions: listOpts, }) }