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

Function reconstruct_line_from_leaf_ops

atomic-repository/src/diff_engine.rs:974–994  ·  view source on GitHub ↗

Reconstruct a line's text content from its leaf operations.

(leaf_ops: &[LeafOp])

Source from the content-addressed store, hash-verified

972
973/// Reconstruct a line's text content from its leaf operations.
974pub fn reconstruct_line_from_leaf_ops(leaf_ops: &[LeafOp]) -> String {
975 let mut line = String::new();
976 for leaf_op in leaf_ops {
977 match leaf_op {
978 LeafOp::Insert { content, .. } => {
979 if let Ok(text) = std::str::from_utf8(content) {
980 line.push_str(text);
981 }
982 }
983 LeafOp::Replace { new_content, .. } => {
984 if let Ok(text) = std::str::from_utf8(new_content) {
985 line.push_str(text);
986 }
987 }
988 LeafOp::Delete { .. } | LeafOp::Restore { .. } => {
989 // These don't add content to the line
990 }
991 }
992 }
993 line
994}
995
996fn is_git_import_change(change: &Change) -> bool {
997 change

Callers 2

change_file_diffs_withFunction · 0.85
change_file_diffs_withFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected