diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go index 1d0a468153277593bcef6a9a8178f2e418187ea3..f606d2da092156139eb3878aed9838745828b16f 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 0f45404c63aaca27d672b550610e6544ccc74364..4397a527f16061a2019c76ed015aa8ae2bdef639 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 e4771d2c1001eae39a0840bdfe1c277cc916832e..f0a6f0c87f5d49cff470891c6ac35e6c807fc747 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 dfc851fded10d571eb38a9432ed058a63471d98a..39aebccb9a0c6d246d4be633b4902cf222da4932 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 } diff --git a/repository/config_git.go b/repository/config_git.go index cff82afb0b40baf65d6b18027c7851148ff630a8..c4d222cf19218975c9c6f52061bb687d59e3b21c 100644 --- a/repository/config_git.go +++ b/repository/config_git.go @@ -66,11 +66,7 @@ func (gc *gitConfig) ReadAll(keyPrefix string) (map[string]string, error) { continue } - parts := strings.Fields(line) - if len(parts) != 2 { - return nil, fmt.Errorf("bad git config: %s", line) - } - + parts := strings.SplitN(line, " ", 2) result[parts[0]] = parts[1] }