MCPcopy Index your code
hub / github.com/git-bug/git-bug / ImportAll

Method ImportAll

bridge/gitlab/import.go:56–101  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

54// ImportAll iterate over all the configured repository issues (notes) and ensure the creation
55// of the missing issues / comments / label events / title changes ...
56func (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
103func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue) (*cache.BugCache, error) {
104 // ensure issue author

Callers 2

TestGitlabImportFunction · 0.95
TestGitlabPushPullFunction · 0.95

Calls 15

ensureIssueMethod · 0.95
ensureIssueEventMethod · 0.95
NewImportErrorFunction · 0.92
IdTypeAlias · 0.92
NewImportNothingFunction · 0.92
closeFunction · 0.85
IssuesFunction · 0.85
SortedEventsFunction · 0.85
NotesFunction · 0.85
LabelEventsFunction · 0.85
StateEventsFunction · 0.85
ErrorfMethod · 0.80

Tested by 2

TestGitlabImportFunction · 0.76
TestGitlabPushPullFunction · 0.76