From 3384d1b26bea41224c260b1912c51e0564571422 Mon Sep 17 00:00:00 2001 From: Josh Bialkowski Date: Mon, 16 Dec 2019 09:09:42 -0800 Subject: [PATCH] codereview #6: don't fail one warning * presence of an error in the import event doesn't indicate failure --- bridge/core/bridge.go | 2 +- bridge/core/import.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go index c6731ff9a06ceeea306a1950bc62ebb517d3d3b6..95c0c2c4ff195892661d2f8cbd0e028ac46844d5 100644 --- a/bridge/core/bridge.go +++ b/bridge/core/bridge.go @@ -330,7 +330,7 @@ func (b *Bridge) ImportAllSince(ctx context.Context, since time.Time) (<-chan Im // relay all events while checking that everything went well for event := range events { - if event.Err != nil { + if event.Event == ImportEventError { noError = false } out <- event diff --git a/bridge/core/import.go b/bridge/core/import.go index 109fae85807d16e83448dfa6300a8fe00a63335d..3b1f3ac38d59498209a90fcca0090acd1d47fff5 100644 --- a/bridge/core/import.go +++ b/bridge/core/import.go @@ -2,6 +2,7 @@ package core import ( "fmt" + "strings" "github.com/MichaelMure/git-bug/entity" ) @@ -71,10 +72,18 @@ func (er ImportResult) String() string { } return fmt.Sprintf("import error: %s", er.Err.Error()) case ImportEventWarning: + parts := make([]string, 0, 4) + parts = append(parts, "warning:") if er.ID != "" { - return fmt.Sprintf("warning at id %s: %s", er.ID, er.Err.Error()) + parts = append(parts, fmt.Sprintf("at id %s", er.ID)) } - return fmt.Sprintf("warning: %s", er.Err.Error()) + if er.Reason != "" { + parts = append(parts, fmt.Sprintf("reason: %s", er.Reason)) + } + if er.Err != nil { + parts = append(parts, fmt.Sprintf("err: %s", er.Err)) + } + return strings.Join(parts, " ") default: panic("unknown import result")