Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Jul 30, 2024
1 parent a12fd15 commit 10ebf3d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 26 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rayon = "1.10.0"
tokio = { version = "1.39.2", features = ["full"] }
git2 = { version = "0.19.0" }
num_cpus = "1.16.0"
regex = "1.10.5"

[build-dependencies]
serde = { version = "1.0.204", features = ["derive"] }
Expand Down
41 changes: 29 additions & 12 deletions Source/Fn/Binary/Command/Sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,35 @@
/// };
/// Fn(option);
/// ```
pub fn Fn(Option { Entry, Pattern, Separator, .. }: Option) {
Entry
.into_iter()
.filter_map(|Entry| {
Entry
.last()
.filter(|Last| *Last == &Pattern)
.map(|_| Entry[0..Entry.len() - 1].join(&Separator.to_string()))
})
.for_each(|_Entry| {
// TODO: GENERATE SUMMARY
})
pub async fn Fn(Option { Entry, Pattern, Separator, Omit, .. }: Option) {
futures::future::join_all(
Entry
.into_iter()
.filter_map(|Entry| {
Entry
.last()
.filter(|Last| *Last == &Pattern)
.map(|_| Entry[0..Entry.len() - 1].join(&Separator.to_string()))
})
.map(|Entry| {
let Omit = Omit.clone();

async move {
match crate::Fn::Summary::Fn(
&Entry,
&crate::Fn::Summary::Difference::Option { Omit },
)
.await
{
Ok(Summary) => Ok(Summary),
Err(_Error) => {
Err(format!("Error generating summary for {}: {}", Entry, _Error))
}
}
}
})
.collect::<Vec<_>>(),
).await;
}

use crate::Struct::Binary::Command::Entry::Struct as Option;
21 changes: 14 additions & 7 deletions Source/Fn/Summary/Difference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,35 @@ pub fn Fn(
// );

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("!*");

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 Options),
)?
.print(git2::DiffFormat::Patch, |_, _, line| {
Difference.push_str(std::str::from_utf8(line.content()).unwrap());
.print(git2::DiffFormat::Patch, |Delta, _, Line| {
if !Option
.Omit
.iter()
.map(|Omit: &String| regex::Regex::new(Omit).expect("Cannot Regex."))
.collect::<Vec<_>>()
.iter()
.any(|Omit| {
Omit.is_match(&Delta.old_file().path().unwrap().display().to_string())
|| Omit.is_match(&Delta.new_file().path().unwrap().display().to_string())
}) {
Difference.push_str(std::str::from_utf8(Line.content()).unwrap());
};

true
})?;

Expand Down
2 changes: 1 addition & 1 deletion Source/Struct/Binary/Command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Struct {
Parallel::Fn(Option).await;
}
false => {
Sequential::Fn(Option);
Sequential::Fn(Option).await;
}
};
})
Expand Down
12 changes: 6 additions & 6 deletions Source/Struct/Binary/Command/Option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ impl Struct {
/// Creates a new Struct instance from the provided Option.
pub fn Fn(Option { Separator, .. }: Option) -> Self {
Self {
Exclude: Fn()
Exclude: Command()
.get_one::<String>("Exclude")
.expect("Cannot Exclude.")
.split(" ")
.map(|Exclude| Exclude.to_string())
.collect::<Vec<_>>(),
Parallel: Fn().get_flag("Parallel"),
Pattern: Fn().get_one::<String>("Pattern").expect("Cannot Pattern.").to_owned(),
Root: Fn().get_one::<String>("Root").expect("Cannot Root.").to_owned(),
Parallel: Command().get_flag("Parallel"),
Pattern: Command().get_one::<String>("Pattern").expect("Cannot Pattern.").to_owned(),
Root: Command().get_one::<String>("Root").expect("Cannot Root.").to_owned(),
Separator,
Omit: Fn()
Omit: Command()
.get_many::<String>("Omit")
.expect("Cannot Omit.")
.map(|Omit| Omit.to_string())
Expand All @@ -42,7 +42,7 @@ impl Struct {
}
}

use crate::{Fn::Binary::Command::Fn, Struct::Binary::Command::Struct as Option};
use crate::{Fn::Binary::Command::Fn as Command, Struct::Binary::Command::Struct as Option};

pub type Command = Vec<String>;
pub type Parallel = bool;
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 10ebf3d

Please sign in to comment.