From f15206e7b1d60239f4e42c618297554bda524b5e Mon Sep 17 00:00:00 2001 From: Josh Bialkowski Date: Fri, 13 Dec 2019 13:17:26 -0800 Subject: * Fix git config reader can't read values with spaces * Add NewImportWarning for things that aren't exactly errors. Use this for unhandled changelog events. * Add NewExportWarning for things that aren't exactly errors. Use this for un-exportable status changes. --- bridge/core/export.go | 17 +++++++++++++++++ bridge/core/import.go | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'bridge') diff --git a/bridge/core/export.go b/bridge/core/export.go index 0f45404c..4397a527 100644 --- a/bridge/core/export.go +++ b/bridge/core/export.go @@ -29,6 +29,10 @@ const ( // Error happened during export ExportEventError + + // Something wrong happened during export that is worth notifying to the user + // but not severe enough to consider the export a failure. + ExportEventWarning ) // ExportResult is an event that is emitted during the export process, to @@ -65,6 +69,11 @@ func (er ExportResult) String() string { return fmt.Sprintf("export error at %s: %s", er.ID, er.Err.Error()) } return fmt.Sprintf("export error: %s", er.Err.Error()) + case ExportEventWarning: + if er.ID != "" { + return fmt.Sprintf("warning at %s: %s", er.ID, er.Err.Error()) + } + return fmt.Sprintf("warning: %s", er.Err.Error()) default: panic("unknown export result") @@ -79,6 +88,14 @@ func NewExportError(err error, id entity.Id) ExportResult { } } +func NewExportWarning(err error, id entity.Id) ExportResult { + return ExportResult{ + ID: id, + Err: err, + Event: ExportEventWarning, + } +} + func NewExportNothing(id entity.Id, reason string) ExportResult { return ExportResult{ ID: id, diff --git a/bridge/core/import.go b/bridge/core/import.go index e4771d2c..5f138da7 100644 --- a/bridge/core/import.go +++ b/bridge/core/import.go @@ -31,6 +31,10 @@ const ( // Error happened during import ImportEventError + + // Something wrong happened during import that is worth notifying to the user + // but not severe enough to consider the import a failure. + ImportEventWarning ) // ImportResult is an event that is emitted during the import process, to @@ -69,6 +73,12 @@ func (er ImportResult) String() string { return fmt.Sprintf("import error at id %s: %s", er.ID, er.Err.Error()) } return fmt.Sprintf("import error: %s", er.Err.Error()) + case ImportEventWarning: + if er.ID != "" { + return fmt.Sprintf("warning at id %s: %s", er.ID, er.Err.Error()) + } + return fmt.Sprintf("warning: %s", er.Err.Error()) + default: panic("unknown import result") } @@ -82,6 +92,14 @@ func NewImportError(err error, id entity.Id) ImportResult { } } +func NewImportWarning(err error, id entity.Id) ImportResult { + return ImportResult{ + Err: err, + ID: id, + Event: ImportEventWarning, + } +} + func NewImportNothing(id entity.Id, reason string) ImportResult { return ImportResult{ ID: id, -- cgit From a785bcdad6296b3babeb62ef3e91d66450730244 Mon Sep 17 00:00:00 2001 From: Josh Bialkowski Date: Mon, 16 Dec 2019 09:09:42 -0800 Subject: 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(-) (limited to 'bridge') diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go index 1d0a4681..f606d2da 100644 --- a/bridge/core/bridge.go +++ b/bridge/core/bridge.go @@ -347,7 +347,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 5f138da7..f0a6f0c8 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" ) @@ -74,10 +75,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") -- cgit From ee48aef489c91a99b665ab1cd783e241611a3841 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 4 Jan 2020 13:10:53 +0100 Subject: github: warning when the comment to be edited is missing instead of failing fix #286 --- bridge/github/import.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bridge') diff --git a/bridge/github/import.go b/bridge/github/import.go index dfc851fd..39aebccb 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -201,6 +201,11 @@ func (gi *githubImporter) ensureIssue(repo *cache.RepoCache, issue issueTimeline // other edits will be added as CommentEdit operations target, err := b.ResolveOperationWithMetadata(metaKeyGithubId, parseId(issue.Id)) + if err == cache.ErrNoMatchingOp { + // original comment is missing somehow, issuing a warning + gi.out <- core.NewImportWarning(fmt.Errorf("comment ID %s to edit is missing", parseId(issue.Id)), b.Id()) + continue + } if err != nil { return nil, err } -- cgit