From dd6bc399960509307b546b9bb0f468dcb549ec07 Mon Sep 17 00:00:00 2001 From: Cezar Craciunoiu Date: Tue, 9 Jan 2024 17:22:54 +0200 Subject: [PATCH] fix(merge): Do not fail on backup errors Signed-off-by: Cezar Craciunoiu --- cmd/governctl/pr/merge.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/governctl/pr/merge.go b/cmd/governctl/pr/merge.go index e8c4721..d6e59f3 100644 --- a/cmd/governctl/pr/merge.go +++ b/cmd/governctl/pr/merge.go @@ -289,13 +289,13 @@ func (opts *Merge) Run(ctx context.Context, args []string) error { cmd = exec.Command("gh", "auth", "token") cmd.Stderr = log.G(ctx).WriterLevel(logrus.ErrorLevel) if output, err = cmd.Output(); err != nil { - return fmt.Errorf("could not backup token: %w", err) + log.G(ctx).Warn("no token to back up, skipping") + token = "" + } else { + token = string(output) } - token = string(output) - if strings.HasPrefix(token, "no oauth token found") { - token = "" - } else if !strings.HasPrefix(token, "gh") { + if token != "" && !strings.HasPrefix(token, "gh") { return fmt.Errorf("could not backup token, invalid format (try running `gh auth token` manually): %w", err) }