diff options
author | Alexander Scharinger <rng.dynamics@gmail.com> | 2021-03-28 12:16:13 +0200 |
---|---|---|
committer | Alexander Scharinger <rng.dynamics@gmail.com> | 2021-03-28 12:16:13 +0200 |
commit | b2e98ef07f3083db303099fbcedbd98a33ad1164 (patch) | |
tree | 31cd9600a1f72e12b8d6db6342feae5ae9826eac /bridge/github/import.go | |
parent | db57227ae53d3e8bba8a5cf939fb2b165d9ceaaf (diff) | |
download | git-bug-b2e98ef07f3083db303099fbcedbd98a33ad1164.tar.gz |
Github bridge: refactor message handling
Diffstat (limited to 'bridge/github/import.go')
-rw-r--r-- | bridge/github/import.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/bridge/github/import.go b/bridge/github/import.go index d2e5d659..619c1c1e 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -62,11 +62,12 @@ func (gi *githubImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, // We need the current event and one look ahead event. currEvent = nextEvent if currEvent == nil { - currEvent = gi.mediator.NextImportEvent() + currEvent = gi.getEventHandleMsgs() } if currEvent == nil { break } + nextEvent = gi.getEventHandleMsgs() switch event := currEvent.(type) { case MessageEvent: @@ -78,7 +79,6 @@ func (gi *githubImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, return } // second: create new issue - nextEvent = gi.mediator.NextImportEvent() switch next := nextEvent.(type) { case IssueEditEvent: // consuming and using next event @@ -100,7 +100,6 @@ func (gi *githubImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, return } case TimelineEvent: - nextEvent = gi.mediator.NextImportEvent() if next, ok := nextEvent.(CommentEditEvent); ok && event.Typename == "IssueComment" { // consuming and using next event nextEvent = nil @@ -136,6 +135,19 @@ func (gi *githubImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, return out, nil } +func (gi *githubImporter) getEventHandleMsgs() ImportEvent { + for { + // read event from import mediator + event := gi.mediator.NextImportEvent() + // consume (and use) all message events + if e, ok := event.(MessageEvent); ok { + fmt.Println(e.msg) + continue + } + return event + } +} + func (gi *githubImporter) commit(b *cache.BugCache, out chan<- core.ImportResult) error { if b == nil { return nil |