diff options
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/core/bridge.go | 2 | ||||
-rw-r--r-- | bridge/core/export.go | 17 | ||||
-rw-r--r-- | bridge/core/import.go | 27 | ||||
-rw-r--r-- | bridge/github/import.go | 5 |
4 files changed, 50 insertions, 1 deletions
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/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..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" ) @@ -31,6 +32,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 +74,20 @@ 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: + parts := make([]string, 0, 4) + parts = append(parts, "warning:") + if er.ID != "" { + parts = append(parts, fmt.Sprintf("at id %s", er.ID)) + } + 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") } @@ -82,6 +101,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, 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 } |