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

Method ExportAll

bridge/github/export.go:131–196  ·  view source on GitHub ↗

ExportAll export all event made by the current user to Github

(ctx context.Context, repo *cache.RepoCache, since time.Time)

Source from the content-addressed store, hash-verified

129
130// ExportAll export all event made by the current user to Github
131func (ge *githubExporter) ExportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ExportResult, error) {
132 out := make(chan core.ExportResult)
133 ge.out = out
134
135 var err error
136 // get repository node id
137 ge.repositoryID, err = getRepositoryNodeID(
138 ctx,
139 ge.defaultToken,
140 ge.conf[confKeyOwner],
141 ge.conf[confKeyProject],
142 )
143 if err != nil {
144 return nil, err
145 }
146
147 go func() {
148 defer close(out)
149
150 // query all labels
151 err = ge.cacheGithubLabels(ctx, ge.defaultClient)
152 if err != nil {
153 out <- core.NewExportError(errors.Wrap(err, "can't obtain Github labels"), "")
154 return
155 }
156
157 allIdentitiesIds := make([]entity.Id, 0, len(ge.identityClient))
158 for id := range ge.identityClient {
159 allIdentitiesIds = append(allIdentitiesIds, id)
160 }
161
162 allBugsIds := repo.Bugs().AllIds()
163
164 for _, id := range allBugsIds {
165 b, err := repo.Bugs().Resolve(id)
166 if err != nil {
167 out <- core.NewExportError(errors.Wrap(err, "can't load bug"), id)
168 return
169 }
170
171 select {
172
173 case <-ctx.Done():
174 // stop iterating if context cancel function is called
175 return
176
177 default:
178 snapshot := b.Snapshot()
179
180 // ignore issues created before since date
181 // TODO: compare the Lamport time instead of using the unix time
182 if snapshot.CreateTime.Before(since) {
183 out <- core.NewExportNothing(b.Id(), "bug created before the since date")
184 continue
185 }
186
187 if snapshot.HasAnyActor(allIdentitiesIds...) {
188 // try to export the bug and it associated events

Callers 1

TestGithubPushPullFunction · 0.95

Calls 12

cacheGithubLabelsMethod · 0.95
exportBugMethod · 0.95
NewExportErrorFunction · 0.92
NewExportNothingFunction · 0.92
getRepositoryNodeIDFunction · 0.85
closeFunction · 0.85
AllIdsMethod · 0.80
BugsMethod · 0.80
SnapshotMethod · 0.80
HasAnyActorMethod · 0.80
ResolveMethod · 0.65
IdMethod · 0.65

Tested by 1

TestGithubPushPullFunction · 0.76