From d6d5978b6dbba1adffd91ff8b86bd5e8465978f5 Mon Sep 17 00:00:00 2001 From: amine Date: Tue, 19 Nov 2019 20:12:07 +0100 Subject: [PATCH] bridge/launchpad: importer correctly emit NothingEvent --- bridge/github/import.go | 2 +- bridge/launchpad/import.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bridge/github/import.go b/bridge/github/import.go index b89e7e02008c4b8e91a3fb00689e3c937bbc2533..864440574fc59881fc00c634473752d7e6da564e 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -388,7 +388,6 @@ func (gi *githubImporter) ensureTimelineComment(repo *cache.RepoCache, b *cache. for i, edit := range edits { if i == 0 && targetOpID != "" { // The first edit in the github result is the comment creation itself, we already have that - gi.out <- core.NewImportNothing("", "comment already imported") continue } @@ -418,6 +417,7 @@ func (gi *githubImporter) ensureTimelineComment(repo *cache.RepoCache, b *cache. if err != nil { return err } + gi.out <- core.NewImportComment(op.Id()) // set target for the nexr edit now that the comment is created targetOpID = op.Id() diff --git a/bridge/launchpad/import.go b/bridge/launchpad/import.go index 178945b6f1c7fef20db866fabda446a6b56c26fa..59fc5c5f23f91384dd32b5d79abcfa3c9827357d 100644 --- a/bridge/launchpad/import.go +++ b/bridge/launchpad/import.go @@ -103,8 +103,6 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach /* Handle messages */ if len(lpBug.Messages) == 0 { - err := fmt.Sprintf("bug doesn't have any comments") - out <- core.NewImportNothing(entity.Id(lpBugID), err) return } @@ -149,8 +147,9 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach out <- core.NewImportComment(op.Id()) } - err = b.CommitAsNeeded() - if err != nil { + if !b.NeedCommit() { + out <- core.NewImportNothing(b.Id(), "no imported operation") + } else if err := b.Commit(); err != nil { out <- core.NewImportError(err, "") return }