(&mut self, repo: &Repository, parsed: &ParsedCommit)
| 497 | } |
| 498 | |
| 499 | fn seed_missing_modified_files(&mut self, repo: &Repository, parsed: &ParsedCommit) { |
| 500 | for file in &parsed.files { |
| 501 | if file.operation != FileOperation::Modified || self.files.contains_key(&file.path) { |
| 502 | continue; |
| 503 | } |
| 504 | let Some(old_content) = file.old_content.as_deref() else { |
| 505 | continue; |
| 506 | }; |
| 507 | |
| 508 | let old_lines: Vec<Vec<u8>> = if Encoding::detect(old_content) == Encoding::Binary |
| 509 | || is_generated_diff_skip_path(&file.path) |
| 510 | { |
| 511 | if old_content.is_empty() { |
| 512 | Vec::new() |
| 513 | } else { |
| 514 | vec![old_content.to_vec()] |
| 515 | } |
| 516 | } else { |
| 517 | split_graph_first_lines(old_content) |
| 518 | .into_iter() |
| 519 | .map(|line| line.to_vec()) |
| 520 | .collect() |
| 521 | }; |
| 522 | |
| 523 | let seed = match repo.import_line_index_seed(&file.path) { |
| 524 | Ok(Some(seed)) => seed, |
| 525 | Ok(None) => continue, |
| 526 | Err(err) => { |
| 527 | trace_git_import(format!( |
| 528 | "{}: could not seed line index for {}: {}", |
| 529 | parsed.short_sha, file.path, err |
| 530 | )); |
| 531 | continue; |
| 532 | } |
| 533 | }; |
| 534 | |
| 535 | if seed.lines.len() != old_lines.len() { |
| 536 | trace_git_import(format!( |
| 537 | "{}: not seeding line index for {}: graph lines={} git old lines={}", |
| 538 | parsed.short_sha, |
| 539 | file.path, |
| 540 | seed.lines.len(), |
| 541 | old_lines.len() |
| 542 | )); |
| 543 | continue; |
| 544 | } |
| 545 | |
| 546 | let mut imported_changes = HashSet::new(); |
| 547 | let lines = seed |
| 548 | .lines |
| 549 | .iter() |
| 550 | .zip(old_lines) |
| 551 | .map(|(line, content)| { |
| 552 | imported_changes.insert(line.incoming_by); |
| 553 | ImportLine { |
| 554 | change: line.change, |
| 555 | start: line.start, |
| 556 | end: line.end, |
no test coverage detected