Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Hristov <Nikola@PlayForm.Cloud>
  • Loading branch information
NikolaRHristov committed Jul 30, 2024
1 parent f05e050 commit 55b69a2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions Source/Fn/Summary/Difference.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::fmt::Debug;

Check warning on line 1 in Source/Fn/Summary/Difference.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

unused import: `core::fmt::Debug`

Check warning on line 1 in Source/Fn/Summary/Difference.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

unused import: `core::fmt::Debug`

/// Calculates the difference between two summaries.
///
/// # Arguments
Expand All @@ -23,29 +25,49 @@ pub fn Fn(
Option: &Option,
) -> Result<String, git2::Error> {
let mut Difference = String::new();

Check warning on line 27 in Source/Fn/Summary/Difference.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

variable does not need to be mutable

Check warning on line 27 in Source/Fn/Summary/Difference.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

variable does not need to be mutable
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::<Vec<String>>()
// .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::<Vec<String>>()
.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)
}
Expand Down
Binary file modified Target/release/PSummary.exe
Binary file not shown.
Binary file modified Target/release/Summary.exe
Binary file not shown.

0 comments on commit 55b69a2

Please sign in to comment.