bridge/launchpad: importer correctly emit NothingEvent

amine created

Change summary

bridge/github/import.go    | 2 +-
bridge/launchpad/import.go | 7 +++----
2 files changed, 4 insertions(+), 5 deletions(-)

Detailed changes

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()

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
 				}