diff --git a/Source/Fn/Summary/Difference.rs b/Source/Fn/Summary/Difference.rs index 1634714..5d0e6be 100644 --- a/Source/Fn/Summary/Difference.rs +++ b/Source/Fn/Summary/Difference.rs @@ -1,3 +1,5 @@ +use core::fmt::Debug; + /// Calculates the difference between two summaries. /// /// # Arguments @@ -23,29 +25,49 @@ pub fn Fn( Option: &Option, ) -> Result { let mut Difference = String::new(); + let mut Options = git2::DiffOptions::new(); + + // Options.pathspec( + // std::ffi::CString::new( + // std::iter::once("*".to_string()) + // .chain(Option.Omit.iter().map(|Omit| format!("{}", Omit))) + // .collect::>() + // .join("\0"), + // ) + // .expect("Cannot create CString"), + // ); + + Options.indent_heuristic(true); + + Options.minimal(true); + + Options.force_text(true); + + Options.ignore_blank_lines(true); + Options.ignore_case(true); + Options.ignore_filemode(true); + Options.ignore_whitespace(true); + Options.ignore_whitespace_change(true); + Options.ignore_whitespace_eol(true); + + // Options.pathspec("*\n!tsconfig.json"); Repository .diff_tree_to_tree( Some(&Repository.revparse_single(Start)?.peel_to_commit()?.tree()?), Some(&Repository.revparse_single(End)?.peel_to_commit()?.tree()?), - Some( - &mut git2::DiffOptions::new().pathspec( - std::ffi::CString::new( - Option - .Omit - .iter() - .map(|Omit| format!("!{}", Omit)) - .collect::>() - .join("\0"), - ) - .expect("Cannot create CString"), - ), - ), + Some(&mut Options), )? - .print(git2::DiffFormat::Patch, |_, _, line| { - Difference.push_str(std::str::from_utf8(line.content()).unwrap()); - true - })?; + .deltas() + .for_each(|Delta| { + for Omit in &Option.Omit { + if Delta.old_file().path().unwrap().display().to_string().contains(Omit) + || Delta.new_file().path().unwrap().display().to_string().contains(Omit) + { + println!("{:?}", Delta.status()); + } + } + }); Ok(Difference) } diff --git a/Target/release/PSummary.exe b/Target/release/PSummary.exe index 863f733..21a3c8d 100644 Binary files a/Target/release/PSummary.exe and b/Target/release/PSummary.exe differ diff --git a/Target/release/Summary.exe b/Target/release/Summary.exe index 8ab1704..3196308 100644 Binary files a/Target/release/Summary.exe and b/Target/release/Summary.exe differ