From 48bc79a291d6da7e05a555d5f1a95ee91075d410 Mon Sep 17 00:00:00 2001 From: Benjamin Levesque <14175665+benjlevesque@users.noreply.github.com> Date: Wed, 20 Aug 2025 20:26:27 +0200 Subject: [PATCH] fix exit code --- pkg/cmd/auth/status/status.go | 6 ++++-- pkg/cmd/auth/status/status_test.go | 5 ----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/cmd/auth/status/status.go b/pkg/cmd/auth/status/status.go index 52cebccbe..014f3e7b6 100644 --- a/pkg/cmd/auth/status/status.go +++ b/pkg/cmd/auth/status/status.go @@ -189,7 +189,7 @@ func statusRun(opts *StatusOptions) error { if opts.ShowToken && opts.Exporter != nil { fmt.Fprintf(stderr, "`--json` and `--show-token` cannot be used together. To include the token in the JSON output, use `--json token`.") - return cmdutil.SilentError + return nil } statuses := make(map[string]Entries) @@ -200,6 +200,7 @@ func statusRun(opts *StatusOptions) error { "You are not logged into any GitHub hosts. To log in, run: %s\n", cs.Bold("gh auth login")) if opts.Exporter != nil { opts.Exporter.Write(opts.IO, struct{}{}) + return nil } return cmdutil.SilentError } @@ -209,6 +210,7 @@ func statusRun(opts *StatusOptions) error { "You are not logged into any accounts on %s\n", opts.Hostname) if opts.Exporter != nil { opts.Exporter.Write(opts.IO, struct{}{}) + return nil } return cmdutil.SilentError } @@ -283,7 +285,7 @@ func statusRun(opts *StatusOptions) error { } opts.Exporter.Write(opts.IO, statusesForExport) - return err + return nil } prevEntry := false diff --git a/pkg/cmd/auth/status/status_test.go b/pkg/cmd/auth/status/status_test.go index 09b7b9379..567748d82 100644 --- a/pkg/cmd/auth/status/status_test.go +++ b/pkg/cmd/auth/status/status_test.go @@ -550,7 +550,6 @@ func Test_statusRun(t *testing.T) { opts: StatusOptions{ Exporter: defaultJsonExporter(), }, - wantErr: cmdutil.SilentError, wantOut: "{}\n", wantErrOut: "You are not logged into any GitHub hosts. To log in, run: gh auth login\n", }, @@ -563,7 +562,6 @@ func Test_statusRun(t *testing.T) { cfgStubs: func(t *testing.T, c gh.Config) { login(t, c, "github.com", "monalisa", "gho_abc123", "https") }, - wantErr: cmdutil.SilentError, wantOut: "{}\n", wantErrOut: "You are not logged into any accounts on foo.com\n", }, @@ -634,7 +632,6 @@ func Test_statusRun(t *testing.T) { // mock for HeaderHasMinimumScopes api requests to a non-github.com host reg.Register(httpmock.REST("GET", "api/v3/"), httpmock.StatusStringResponse(400, "no bueno")) }, - wantErr: cmdutil.SilentError, wantOut: `{"ghe.io":[{"active":true,"host":"ghe.io","login":"monalisa-ghe","scopes":"","state":"error"}]}` + "\n", }, { @@ -652,7 +649,6 @@ func Test_statusRun(t *testing.T) { return nil, context.DeadlineExceeded }) }, - wantErr: cmdutil.SilentError, wantOut: `{"github.com":[{"active":true,"host":"github.com","login":"monalisa","scopes":"","state":"timeout"}]}` + "\n", }, { @@ -664,7 +660,6 @@ func Test_statusRun(t *testing.T) { cfgStubs: func(t *testing.T, c gh.Config) { login(t, c, "github.com", "monalisa", "abc123", "https") }, - wantErr: cmdutil.SilentError, wantErrOut: "`--json` and `--show-token` cannot be used together. To include the token in the JSON output, use `--json token`.", }, }