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

Method ensureCommentEdit

bridge/github/import.go:401–446  ·  view source on GitHub ↗
(ctx context.Context, repo *cache.RepoCache, b *cache.BugCache, ghTargetId githubv4.ID, edit *userContentEdit)

Source from the content-addressed store, hash-verified

399}
400
401func (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
448func (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)

Callers 2

ImportAllMethod · 0.95
ensureIssueEditMethod · 0.95

Calls 8

ensurePersonMethod · 0.95
CombineIdsFunction · 0.92
CleanupFunction · 0.92
NewImportCommentEditionFunction · 0.92
parseIdFunction · 0.85
EditCommentRawMethod · 0.80
IdMethod · 0.65

Tested by

no test coverage detected