From 12f6fd61be835ca37e6a4e8a17abd4b8175e6ba0 Mon Sep 17 00:00:00 2001 From: Amine Hilaly Date: Fri, 10 May 2019 12:02:44 +0200 Subject: call NextIssueEdit from ensureIssue --- bridge/github/import.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'bridge/github/import.go') diff --git a/bridge/github/import.go b/bridge/github/import.go index 2cdd7579..da0ca2fe 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -54,22 +54,15 @@ func (gi *githubImporter) ImportAll(repo *cache.RepoCache, since time.Time) erro fmt.Printf("importing issue: %v %v\n", gi.importedIssues+1, issue.Title) gi.importedIssues++ - // get issue edits - issueEdits := []userContentEdit{} - for gi.iterator.NextIssueEdit() { - issueEdits = append(issueEdits, gi.iterator.IssueEditValue()) - } - // create issue - b, err := gi.ensureIssue(repo, issue, issueEdits) + b, err := gi.ensureIssue(repo, issue) if err != nil { return fmt.Errorf("issue creation: %v", err) } // loop over timeline items for gi.iterator.NextTimeline() { - item := gi.iterator.TimelineValue() - if err := gi.ensureTimelineItem(repo, b, item); err != nil { + if err := gi.ensureTimelineItem(repo, b, gi.iterator.TimelineValue()); err != nil { return fmt.Errorf("timeline event creation: %v", err) } } @@ -90,7 +83,7 @@ func (gi *githubImporter) ImportAll(repo *cache.RepoCache, since time.Time) erro return nil } -func (gi *githubImporter) ensureIssue(repo *cache.RepoCache, issue issueTimeline, issueEdits []userContentEdit) (*cache.BugCache, error) { +func (gi *githubImporter) ensureIssue(repo *cache.RepoCache, issue issueTimeline) (*cache.BugCache, error) { // ensure issue author author, err := gi.ensurePerson(repo, issue.Author) if err != nil { @@ -103,6 +96,12 @@ func (gi *githubImporter) ensureIssue(repo *cache.RepoCache, issue issueTimeline return nil, err } + // get issue edits + issueEdits := []userContentEdit{} + for gi.iterator.NextIssueEdit() { + issueEdits = append(issueEdits, gi.iterator.IssueEditValue()) + } + // if issueEdits is empty if len(issueEdits) == 0 { if err == bug.ErrBugNotExist { -- cgit