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:2927–2954  ·  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

2925}
2926
2927fn record_git_diff_add_fast(
2928 path: &str,
2929 new_content: &[u8],
2930 diff_lines: &[GitDiffLine],
2931 kind: atomic_core::record::workflow::DetectionKind,
2932) -> Option<RecordedFile> {
2933 let encoding = Encoding::detect(new_content);
2934 if encoding == Encoding::Binary {
2935 return None;
2936 }
2937
2938 let mut recorded = RecordedFile::new(path);
2939 recorded.set_kind(kind);
2940 recorded.set_encoding(encoding);
2941 recorded.add_hunk(BuiltHunk::new_edit(
2942 Local::new(path, 1),
2943 Some(encoding),
2944 0,
2945 new_content.len() as u64,
2946 ));
2947 recorded.set_content(new_content.to_vec());
2948
2949 let (git_file_ops, git_stats) =
2950 atomic_core::record::workflow::build_crdt_ops_from_git_diff(path, diff_lines);
2951 recorded.set_crdt_ops(git_file_ops);
2952 recorded.set_crdt_stats(git_stats);
2953 Some(recorded)
2954}
2955
2956fn build_linewise_crdt_ops_for_added_file(
2957 path: &str,

Callers

nothing calls this directly

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