ImportAll iterate over all the configured repository issues (notes) and ensure the creation of the missing issues / comments / label events / title changes ...
(ctx context.Context, repo *cache.RepoCache, since time.Time)
| 54 | // ImportAll iterate over all the configured repository issues (notes) and ensure the creation |
| 55 | // of the missing issues / comments / label events / title changes ... |
| 56 | func (gi *gitlabImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ImportResult, error) { |
| 57 | out := make(chan core.ImportResult) |
| 58 | gi.out = out |
| 59 | |
| 60 | go func() { |
| 61 | defer close(out) |
| 62 | |
| 63 | for issue := range Issues(ctx, gi.client, gi.conf[confKeyProjectID], since) { |
| 64 | |
| 65 | b, err := gi.ensureIssue(repo, issue) |
| 66 | if err != nil { |
| 67 | err := fmt.Errorf("issue creation: %v", err) |
| 68 | out <- core.NewImportError(err, "") |
| 69 | return |
| 70 | } |
| 71 | |
| 72 | issueEvents := SortedEvents( |
| 73 | Notes(ctx, gi.client, issue), |
| 74 | LabelEvents(ctx, gi.client, issue), |
| 75 | StateEvents(ctx, gi.client, issue), |
| 76 | ) |
| 77 | |
| 78 | for e := range issueEvents { |
| 79 | if e, ok := e.(ErrorEvent); ok { |
| 80 | out <- core.NewImportError(e.Err, "") |
| 81 | continue |
| 82 | } |
| 83 | if err := gi.ensureIssueEvent(repo, b, issue, e); err != nil { |
| 84 | err := fmt.Errorf("unable to create issue event: %v", err) |
| 85 | out <- core.NewImportError(err, entity.Id(e.ID())) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | if !b.NeedCommit() { |
| 90 | out <- core.NewImportNothing(b.Id(), "no imported operation") |
| 91 | } else if err := b.Commit(); err != nil { |
| 92 | // commit bug state |
| 93 | err := fmt.Errorf("bug commit: %v", err) |
| 94 | out <- core.NewImportError(err, "") |
| 95 | return |
| 96 | } |
| 97 | } |
| 98 | }() |
| 99 | |
| 100 | return out, nil |
| 101 | } |
| 102 | |
| 103 | func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue) (*cache.BugCache, error) { |
| 104 | // ensure issue author |