MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / record_git_diff_add_fast

Function record_git_diff_add_fast

atomic-cli/src/commands/git/parallel.rs:995–1022  ·  view source on GitHub ↗
(
    path: &str,
    new_content: &[u8],
    diff_lines: &[GitDiffLine],
    kind: atomic_core::record::workflow::DetectionKind,
)

Source from the content-addressed store, hash-verified

993}
994
995fn 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
1024fn build_linewise_crdt_ops_for_added_file(
1025 path: &str,

Callers 1

write_commitMethod · 0.85

Calls 8

set_contentMethod · 0.80
set_crdt_opsMethod · 0.80
set_crdt_statsMethod · 0.80
set_kindMethod · 0.45
set_encodingMethod · 0.45
add_hunkMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected