(ctx context.Context, repo *cache.RepoCache, b *cache.BugCache, ghTargetId githubv4.ID, edit *userContentEdit)
| 399 | } |
| 400 | |
| 401 | func (gi *githubImporter) ensureCommentEdit(ctx context.Context, repo *cache.RepoCache, b *cache.BugCache, ghTargetId githubv4.ID, edit *userContentEdit) error { |
| 402 | // find comment |
| 403 | target, err := b.ResolveOperationWithMetadata(metaKeyGithubId, parseId(ghTargetId)) |
| 404 | if err != nil { |
| 405 | return err |
| 406 | } |
| 407 | // check if the comment edition already exist |
| 408 | _, err = b.ResolveOperationWithMetadata(metaKeyGithubId, parseId(edit.Id)) |
| 409 | if err == nil { |
| 410 | return nil |
| 411 | } |
| 412 | if err != cache.ErrNoMatchingOp { |
| 413 | // real error |
| 414 | return err |
| 415 | } |
| 416 | |
| 417 | editor, err := gi.ensurePerson(ctx, repo, edit.Editor) |
| 418 | if err != nil { |
| 419 | return err |
| 420 | } |
| 421 | |
| 422 | if edit.DeletedAt != nil { |
| 423 | // comment deletion, not supported yet |
| 424 | return nil |
| 425 | } |
| 426 | |
| 427 | commentId := entity.CombineIds(b.Id(), target) |
| 428 | |
| 429 | // comment edition |
| 430 | _, err = b.EditCommentRaw( |
| 431 | editor, |
| 432 | edit.CreatedAt.Unix(), |
| 433 | commentId, |
| 434 | text.Cleanup(string(*edit.Diff)), |
| 435 | map[string]string{ |
| 436 | metaKeyGithubId: parseId(edit.Id), |
| 437 | }, |
| 438 | ) |
| 439 | |
| 440 | if err != nil { |
| 441 | return err |
| 442 | } |
| 443 | |
| 444 | gi.out <- core.NewImportCommentEdition(b.Id(), commentId) |
| 445 | return nil |
| 446 | } |
| 447 | |
| 448 | func (gi *githubImporter) ensureComment(ctx context.Context, repo *cache.RepoCache, b *cache.BugCache, comment *issueComment, firstEdit *userContentEdit) error { |
| 449 | author, err := gi.ensurePerson(ctx, repo, comment.Author) |
no test coverage detected