MCPcopy Index your code
hub / github.com/harness/harness / fetchDiffCut

Method fetchDiffCut

app/api/controller/pullreq/comment_create.go:372–400  ·  view source on GitHub ↗
(
	ctx context.Context,
	repo *types.RepositoryCore,
	in *CommentCreateInput,
)

Source from the content-addressed store, hash-verified

370}
371
372func (c *Controller) fetchDiffCut(
373 ctx context.Context,
374 repo *types.RepositoryCore,
375 in *CommentCreateInput,
376) (git.DiffCutOutput, error) {
377 // maxDiffLineCount restricts the total length of a code comment diff to 1000 lines.
378 // TODO: This can still lead to wrong code comments in cases like a large file being replaced by one line.
379 const maxDiffLineCount = 1000
380
381 cut, err := c.git.DiffCut(ctx, &git.DiffCutParams{
382 ReadParams: git.ReadParams{RepoUID: repo.GitUID},
383 SourceCommitSHA: in.SourceCommitSHA,
384 TargetCommitSHA: in.TargetCommitSHA,
385 Path: in.Path,
386 LineStart: in.LineStart,
387 LineStartNew: in.LineStartNew,
388 LineEnd: in.LineEnd,
389 LineEndNew: in.LineEndNew,
390 LineLimit: maxDiffLineCount,
391 })
392 if errors.AsStatus(err) == errors.StatusNotFound {
393 return git.DiffCutOutput{}, usererror.BadRequest(errors.Message(err))
394 }
395 if err != nil {
396 return git.DiffCutOutput{}, fmt.Errorf("failed to fetch git diff cut: %w", err)
397 }
398
399 return cut, nil
400}
401
402func (c *Controller) migrateCodeComment(
403 ctx context.Context,

Callers 1

CommentCreateMethod · 0.95

Calls 5

AsStatusFunction · 0.92
BadRequestFunction · 0.92
MessageFunction · 0.92
DiffCutMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected