(
path: &str,
new_content: &[u8],
diff_lines: &[GitDiffLine],
kind: atomic_core::record::workflow::DetectionKind,
)
| 993 | } |
| 994 | |
| 995 | fn record_git_diff_add_fast( |
| 996 | path: &str, |
| 997 | new_content: &[u8], |
| 998 | diff_lines: &[GitDiffLine], |
| 999 | kind: atomic_core::record::workflow::DetectionKind, |
| 1000 | ) -> Option<RecordedFile> { |
| 1001 | let encoding = Encoding::detect(new_content); |
| 1002 | if encoding == Encoding::Binary { |
| 1003 | return None; |
| 1004 | } |
| 1005 | |
| 1006 | let mut recorded = RecordedFile::new(path); |
| 1007 | recorded.set_kind(kind); |
| 1008 | recorded.set_encoding(encoding); |
| 1009 | recorded.add_hunk(BuiltHunk::new_edit( |
| 1010 | Local::new(path, 1), |
| 1011 | Some(encoding), |
| 1012 | 0, |
| 1013 | new_content.len() as u64, |
| 1014 | )); |
| 1015 | recorded.set_content(new_content.to_vec()); |
| 1016 | |
| 1017 | let (git_file_ops, git_stats) = |
| 1018 | atomic_core::record::workflow::build_crdt_ops_from_git_diff(path, diff_lines); |
| 1019 | recorded.set_crdt_ops(git_file_ops); |
| 1020 | recorded.set_crdt_stats(git_stats); |
| 1021 | Some(recorded) |
| 1022 | } |
| 1023 | |
| 1024 | fn build_linewise_crdt_ops_for_added_file( |
| 1025 | path: &str, |
no test coverage detected