| 9 | const char *RESET = "\u001b[0m"; |
| 10 | const char *BLUE = "\u001b[1;94m"; |
| 11 | String TextDiff::get_diff(const String &old_text, const String &new_text) { |
| 12 | std::string old_text_str = old_text.utf8().get_data(); |
| 13 | std::string new_text_str = new_text.utf8().get_data(); |
| 14 | Vector<String> old_text_lines = old_text.split("\n"); |
| 15 | Vector<String> new_text_lines = new_text.split("\n"); |
| 16 | std::vector<std::string> old_text_lines_vec; |
| 17 | std::vector<std::string> new_text_lines_vec; |
| 18 | for (String line : old_text_lines) { |
| 19 | old_text_lines_vec.push_back(line.utf8().get_data()); |
| 20 | } |
| 21 | for (String line : new_text_lines) { |
| 22 | new_text_lines_vec.push_back(line.utf8().get_data()); |
| 23 | } |
| 24 | dtl::Diff<std::string, std::vector<std::string>> d(old_text_lines_vec, new_text_lines_vec); |
| 25 | d.compose(); |
| 26 | d.composeUnifiedHunks(); |
| 27 | std::stringstream ss; |
| 28 | d.printUnifiedFormat(ss); |
| 29 | return String::utf8(ss.str().c_str()); |
| 30 | } |
| 31 | |
| 32 | String TextDiff::get_diff_with_header(const String &old_path, const String &new_path, const String &old_text, const String &new_text) { |
| 33 | String header = "--- a/" + old_path + "\n"; |
nothing calls this directly
no test coverage detected