( ctx context.Context, repo *types.RepositoryCore, in *CommentCreateInput, )
| 370 | } |
| 371 | |
| 372 | func (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 | |
| 402 | func (c *Controller) migrateCodeComment( |
| 403 | ctx context.Context, |
no test coverage detected