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

Method ensureIssueEvent

bridge/gitlab/import.go:150–342  ·  view source on GitHub ↗
(repo *cache.RepoCache, b *cache.BugCache, issue *gitlab.Issue, event Event)

Source from the content-addressed store, hash-verified

148}
149
150func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCache, issue *gitlab.Issue, event Event) error {
151 id, errResolve := b.ResolveOperationWithMetadata(metaKeyGitlabId, event.ID())
152 if errResolve != nil && errResolve != cache.ErrNoMatchingOp {
153 return errResolve
154 }
155
156 // ensure issue author
157 author, err := gi.ensurePerson(repo, event.UserID())
158 if err != nil {
159 return err
160 }
161
162 switch event.Kind() {
163 case EventClosed:
164 if errResolve == nil {
165 return nil
166 }
167
168 op, err := b.CloseRaw(
169 author,
170 event.CreatedAt().Unix(),
171 map[string]string{
172 metaKeyGitlabId: event.ID(),
173 },
174 )
175
176 if err != nil {
177 return err
178 }
179
180 gi.out <- core.NewImportStatusChange(b.Id(), op.Id())
181
182 case EventReopened:
183 if errResolve == nil {
184 return nil
185 }
186
187 op, err := b.OpenRaw(
188 author,
189 event.CreatedAt().Unix(),
190 map[string]string{
191 metaKeyGitlabId: event.ID(),
192 },
193 )
194 if err != nil {
195 return err
196 }
197
198 gi.out <- core.NewImportStatusChange(b.Id(), op.Id())
199
200 case EventDescriptionChanged:
201 firstComment := b.Snapshot().Comments[0]
202 // since gitlab doesn't provide the issue history
203 // we should check for "changed the description" notes and compare issue texts
204 // TODO: Check only one time and ignore next 'description change' within one issue
205 cleanedDesc := text.Cleanup(issue.Description)
206 if errResolve == cache.ErrNoMatchingOp && cleanedDesc != firstComment.Message {
207 // comment edition

Callers 1

ImportAllMethod · 0.95

Calls 15

ensurePersonMethod · 0.95
NewImportStatusChangeFunction · 0.92
CleanupFunction · 0.92
NewImportTitleEditionFunction · 0.92
NewImportCommentFunction · 0.92
NewImportCommentEditionFunction · 0.92
CloseRawMethod · 0.80
OpenRawMethod · 0.80
SnapshotMethod · 0.80
EditCommentRawMethod · 0.80
AddCommentRawMethod · 0.80

Tested by

no test coverage detected