MCPcopy
hub / github.com/harness/harness / migrateCodeComment

Method migrateCodeComment

app/api/controller/pullreq/comment_create.go:402–430  ·  view source on GitHub ↗
(
	ctx context.Context,
	repo *types.RepositoryCore,
	pr *types.PullReq,
	in *CommentCreateInput,
	cc *types.CodeComment,
	cut git.DiffCutOutput,
)

Source from the content-addressed store, hash-verified

400}
401
402func (c *Controller) migrateCodeComment(
403 ctx context.Context,
404 repo *types.RepositoryCore,
405 pr *types.PullReq,
406 in *CommentCreateInput,
407 cc *types.CodeComment,
408 cut git.DiffCutOutput,
409) {
410 needsNewLineMigrate := in.SourceCommitSHA != pr.SourceSHA
411 needsOldLineMigrate := cut.MergeBaseSHA.String() != pr.MergeBaseSHA
412 if !needsNewLineMigrate && !needsOldLineMigrate {
413 return
414 }
415
416 comments := []*types.CodeComment{cc}
417
418 if needsNewLineMigrate {
419 c.codeCommentMigrator.MigrateNew(ctx, repo.GitUID, pr.SourceSHA, comments)
420 }
421 if needsOldLineMigrate {
422 c.codeCommentMigrator.MigrateOld(ctx, repo.GitUID, pr.MergeBaseSHA, comments)
423 }
424
425 if errMigrateUpdate := c.codeCommentView.UpdateAll(ctx, comments); errMigrateUpdate != nil {
426 // non-critical error
427 log.Ctx(ctx).Err(errMigrateUpdate).
428 Msgf("failed to migrate code comment to the latest source/merge-base commit SHA")
429 }
430}
431
432func (c *Controller) reportCommentCreated(
433 ctx context.Context,

Callers 1

CommentCreateMethod · 0.95

Calls 6

MigrateNewMethod · 0.80
MigrateOldMethod · 0.80
MsgfMethod · 0.80
UpdateAllMethod · 0.65
ErrMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected