(&mut self, repo: &Repository, parsed: &ParsedCommit)
| 436 | } |
| 437 | |
| 438 | fn seed_missing_modified_files(&mut self, repo: &Repository, parsed: &ParsedCommit) { |
| 439 | for file in &parsed.files { |
| 440 | if file.operation != FileOperation::Modified || self.files.contains_key(&file.path) { |
| 441 | continue; |
| 442 | } |
| 443 | let Some(old_content) = file.old_content.as_deref() else { |
| 444 | continue; |
| 445 | }; |
| 446 | |
| 447 | let old_lines: Vec<Vec<u8>> = if Encoding::detect(old_content) == Encoding::Binary |
| 448 | || is_generated_diff_skip_path(&file.path) |
| 449 | { |
| 450 | if old_content.is_empty() { |
| 451 | Vec::new() |
| 452 | } else { |
| 453 | vec![old_content.to_vec()] |
| 454 | } |
| 455 | } else { |
| 456 | split_graph_first_lines(old_content) |
| 457 | .into_iter() |
| 458 | .map(|line| line.to_vec()) |
| 459 | .collect() |
| 460 | }; |
| 461 | |
| 462 | let seed = match repo.import_line_index_seed(&file.path) { |
| 463 | Ok(Some(seed)) => seed, |
| 464 | Ok(None) => continue, |
| 465 | Err(err) => { |
| 466 | trace_git_import(format!( |
| 467 | "{}: could not seed line index for {}: {}", |
| 468 | parsed.short_sha, file.path, err |
| 469 | )); |
| 470 | continue; |
| 471 | } |
| 472 | }; |
| 473 | |
| 474 | if seed.lines.len() != old_lines.len() { |
| 475 | trace_git_import(format!( |
| 476 | "{}: not seeding line index for {}: graph lines={} git old lines={}", |
| 477 | parsed.short_sha, |
| 478 | file.path, |
| 479 | seed.lines.len(), |
| 480 | old_lines.len() |
| 481 | )); |
| 482 | continue; |
| 483 | } |
| 484 | |
| 485 | let mut imported_changes = HashSet::new(); |
| 486 | let lines = seed |
| 487 | .lines |
| 488 | .iter() |
| 489 | .zip(old_lines) |
| 490 | .map(|(line, content)| { |
| 491 | imported_changes.insert(line.incoming_by); |
| 492 | ImportLine { |
| 493 | change: line.change, |
| 494 | start: line.start, |
| 495 | end: line.end, |
no test coverage detected