(repo *cache.RepoCache, b *cache.BugCache, issue *gitlab.Issue, event Event)
| 148 | } |
| 149 | |
| 150 | func (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 |
no test coverage detected