Reconstruct a line's text content from its leaf operations.
(leaf_ops: &[LeafOp])
| 972 | |
| 973 | /// Reconstruct a line's text content from its leaf operations. |
| 974 | pub 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 | |
| 996 | fn is_git_import_change(change: &Change) -> bool { |
| 997 | change |
no outgoing calls
no test coverage detected