(&mut self, repo: &Repository, parsed: &ParsedCommit)
| 549 | } |
| 550 | |
| 551 | fn seed_missing_modified_files(&mut self, repo: &Repository, parsed: &ParsedCommit) { |
| 552 | for file in &parsed.files { |
| 553 | if file.operation != FileOperation::Modified || self.files.contains_key(&file.path) { |
| 554 | continue; |
| 555 | } |
| 556 | let Some(old_content) = file.old_content.as_deref() else { |
| 557 | continue; |
| 558 | }; |
| 559 | |
| 560 | let old_lines: Vec<Vec<u8>> = if Encoding::detect(old_content) == Encoding::Binary |
| 561 | || is_generated_diff_skip_path(&file.path) |
| 562 | { |
| 563 | if old_content.is_empty() { |
| 564 | Vec::new() |
| 565 | } else { |
| 566 | vec![old_content.to_vec()] |
| 567 | } |
| 568 | } else { |
| 569 | split_graph_first_lines(old_content) |
| 570 | .into_iter() |
| 571 | .map(|line| line.to_vec()) |
| 572 | .collect() |
| 573 | }; |
| 574 | |
| 575 | let seed = match repo.import_line_index_seed(&file.path) { |
| 576 | Ok(Some(seed)) => seed, |
| 577 | Ok(None) => continue, |
| 578 | Err(err) => { |
| 579 | trace_git_import(format!( |
| 580 | "{}: could not seed line index for {}: {}", |
| 581 | parsed.short_sha, file.path, err |
| 582 | )); |
| 583 | continue; |
| 584 | } |
| 585 | }; |
| 586 | |
| 587 | if seed.lines.len() != old_lines.len() { |
| 588 | trace_git_import(format!( |
| 589 | "{}: not seeding line index for {}: graph lines={} git old lines={}", |
| 590 | parsed.short_sha, |
| 591 | file.path, |
| 592 | seed.lines.len(), |
| 593 | old_lines.len() |
| 594 | )); |
| 595 | continue; |
| 596 | } |
| 597 | |
| 598 | let mut imported_changes = HashSet::new(); |
| 599 | let lines = seed |
| 600 | .lines |
| 601 | .iter() |
| 602 | .zip(old_lines) |
| 603 | .map(|(line, content)| { |
| 604 | imported_changes.insert(line.incoming_by); |
| 605 | ImportLine { |
| 606 | change: line.change, |
| 607 | start: line.start, |
| 608 | end: line.end, |
no test coverage detected