(
repo: &Repository,
change: &atomic_core::change::Change,
hash: &Hash,
)
| 973 | } |
| 974 | |
| 975 | fn recorded_diff( |
| 976 | repo: &Repository, |
| 977 | change: &atomic_core::change::Change, |
| 978 | hash: &Hash, |
| 979 | ) -> CliResult<String> { |
| 980 | use atomic_repository::diff_engine::{change_file_diffs, DiffOutputConfig}; |
| 981 | let (mut files, _) = change_file_diffs( |
| 982 | repo, |
| 983 | change, |
| 984 | hash, |
| 985 | &DiffOutputConfig::new().with_color(false), |
| 986 | ) |
| 987 | .map_err(CliError::Repository)?; |
| 988 | files.sort_by(|a, b| (&a.new_path, &a.old_path).cmp(&(&b.new_path, &b.old_path))); |
| 989 | let mut output = String::new(); |
| 990 | for file in files { |
| 991 | output.push_str(&format!("--- {}\n+++ {}\n", file.old_path, file.new_path)); |
| 992 | if file.is_binary { |
| 993 | output.push_str("Binary content differs\n"); |
| 994 | } |
| 995 | let total: usize = file.hunks.iter().map(|hunk| hunk.lines.len()).sum(); |
| 996 | if total > 3000 { |
| 997 | output.push_str(&format!( |
| 998 | "[diff omitted: {total} lines; use atomic diff -c {}]\n", |
| 999 | hash.to_base32() |
| 1000 | )); |
| 1001 | continue; |
| 1002 | } |
| 1003 | for hunk in file.hunks { |
| 1004 | output.push_str(&hunk.header()); |
| 1005 | output.push('\n'); |
| 1006 | for line in hunk.lines { |
| 1007 | output.push_str(&line.to_string()); |
| 1008 | output.push('\n'); |
| 1009 | } |
| 1010 | } |
| 1011 | } |
| 1012 | Ok(output) |
| 1013 | } |
| 1014 | |
| 1015 | /// Render the human-readable worklist without writing to a terminal. |
| 1016 | pub fn render(report: &IncrementalReport, details: bool) -> CliResult<String> { |
no test coverage detected