Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Oct 6, 2024
1 parent d5db810 commit 3bab189
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 115 deletions.
3 changes: 1 addition & 2 deletions Source/Fn/Binary/Command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
/// ```rust
/// let matches = Fn();
/// let exclude = matches.value_of("Exclude").unwrap_or("node_modules");
/// let omit =
/// matches.values_of("Omit").unwrap_or_default().collect::<Vec<_>>();
/// let omit = matches.values_of("Omit").unwrap_or_default().collect::<Vec<_>>();
/// let parallel = matches.is_present("Parallel");
/// let pattern = matches.value_of("Pattern").unwrap_or(".git");
/// let root = matches.value_of("Root").unwrap_or(".");
Expand Down
14 changes: 3 additions & 11 deletions Source/Fn/Binary/Command/Entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ pub fn Fn(Option { Exclude, Pattern, Root, Separator, .. }:&Option) -> Return {
.follow_links(false)
.into_iter()
.filter_map(|Entry| {
let Path =
Entry.expect("Cannot Entry.").path().display().to_string();
let Path = Entry.expect("Cannot Entry.").path().display().to_string();

// TODO: Separate this into Entry/Exclude.rs
if !Exclude
Expand All @@ -50,11 +49,7 @@ pub fn Fn(Option { Exclude, Pattern, Root, Separator, .. }:&Option) -> Return {
.filter(|Exclude| *Pattern != *Exclude)
.any(|Exclude| Path.contains(&Exclude))
{
Some(
Path.split(*Separator)
.map(|Entry| Entry.to_string())
.collect(),
)
Some(Path.split(*Separator).map(|Entry| Entry.to_string()).collect())
} else {
None
}
Expand All @@ -64,7 +59,4 @@ pub fn Fn(Option { Exclude, Pattern, Root, Separator, .. }:&Option) -> Return {

use walkdir::WalkDir;

use crate::Struct::Binary::Command::{
Entry::Type as Return,
Option::Struct as Option,
};
use crate::Struct::Binary::Command::{Entry::Type as Return, Option::Struct as Option};
6 changes: 1 addition & 5 deletions Source/Fn/Binary/Command/Parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
///
/// ```rust
/// let options = Option {
/// Entry:vec![vec![
/// "path".to_string(),
/// "to".to_string(),
/// "file.git".to_string(),
/// ]],
/// Entry:vec![vec!["path".to_string(), "to".to_string(), "file.git".to_string()]],
/// Separator:'/',
/// Pattern:".git".to_string(),
/// Omit:vec!["target".to_string()],
Expand Down
22 changes: 7 additions & 15 deletions Source/Fn/Binary/Command/Sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
///
/// ```rust
/// let options = Option {
/// Entry:vec![vec![
/// "path".to_string(),
/// "to".to_string(),
/// "file.git".to_string(),
/// ]],
/// Entry:vec![vec!["path".to_string(), "to".to_string(), "file.git".to_string()]],
/// Separator:'/',
/// Pattern:".git".to_string(),
/// Omit:vec!["target".to_string()],
Expand All @@ -42,9 +38,10 @@ pub async fn Fn(Option { Entry, Pattern, Separator, Omit, .. }:Option) {
Entry
.into_iter()
.filter_map(|Entry| {
Entry.last().filter(|Last| *Last == &Pattern).map(|_| {
Entry[0..Entry.len() - 1].join(&Separator.to_string())
})
Entry
.last()
.filter(|Last| *Last == &Pattern)
.map(|_| Entry[0..Entry.len() - 1].join(&Separator.to_string()))
})
.map(|Entry| {
let Omit = Omit.clone();
Expand All @@ -58,20 +55,15 @@ pub async fn Fn(Option { Entry, Pattern, Separator, Omit, .. }:Option) {
{
Ok(Summary) => Ok((Entry, Summary)),
Err(_Error) => {
Err(format!(
"Error generating summary for {}: {}",
Entry, _Error
))
Err(format!("Error generating summary for {}: {}", Entry, _Error))
},
}
}
}),
)
.await;

crate::Fn::Summary::Group::Fn(
Queue.into_iter().filter_map(Result::ok).collect::<Vec<_>>(),
);
crate::Fn::Summary::Group::Fn(Queue.into_iter().filter_map(Result::ok).collect::<Vec<_>>());
}

use crate::Struct::Binary::Command::Entry::Struct as Option;
46 changes: 11 additions & 35 deletions Source/Fn/Summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
/// # Example
///
/// ```rust
/// let options = crate::Struct::Summary::Difference::Struct {
/// Omit:vec!["(?i)\\.log$".to_string()],
/// };
/// let summary =
/// Fn("/path/to/repo", &options).await.expect("Cannot generate summary.");
/// let options =
/// crate::Struct::Summary::Difference::Struct { Omit:vec!["(?i)\\.log$".to_string()] };
/// let summary = Fn("/path/to/repo", &options).await.expect("Cannot generate summary.");
/// for entry in summary.iter() {
/// println!("{:?}", entry);
/// }
Expand Down Expand Up @@ -62,12 +60,9 @@ pub async fn Fn(
.map(|Commit| {
(
Tag.to_string(),
DateTime::from_timestamp(
Commit.time().seconds(),
0,
)
.unwrap()
.fixed_offset(),
DateTime::from_timestamp(Commit.time().seconds(), 0)
.unwrap()
.fixed_offset(),
)
})
})
Expand All @@ -76,39 +71,25 @@ pub async fn Fn(

Date.sort_by(|A, B| A.1.cmp(&B.1));

let Tag:Vec<String> =
Date.into_iter().map(|(Tag, _)| Tag).collect();
let Tag:Vec<String> = Date.into_iter().map(|(Tag, _)| Tag).collect();

let Head = Repository.head()?;

let First = Repository
.find_commit(First::Fn(&Repository)?)?
.id()
.to_string();
let First = Repository.find_commit(First::Fn(&Repository)?)?.id().to_string();

let Last = Head.peel_to_commit()?.id().to_string();

if Tag.is_empty() {
Insert::Fn(
&Summary,
crate::Fn::Summary::Difference::Fn(
&Repository,
&First,
&Last,
Option,
)?,
crate::Fn::Summary::Difference::Fn(&Repository, &First, &Last, Option)?,
format!("🗣️ Summary from first commit to last commit"),
)
} else {
if let Some(Latest) = Tag.last() {
Insert::Fn(
&Summary,
crate::Fn::Summary::Difference::Fn(
&Repository,
Latest,
&Last,
Option,
)?,
crate::Fn::Summary::Difference::Fn(&Repository, Latest, &Last, Option)?,
format!("🗣️ Summary from {} to last commit", Latest),
);
}
Expand All @@ -119,12 +100,7 @@ pub async fn Fn(

Insert::Fn(
&Summary,
crate::Fn::Summary::Difference::Fn(
&Repository,
&Start,
&End,
Option,
)?,
crate::Fn::Summary::Difference::Fn(&Repository, &Start, &End, Option)?,
format!("🗣️ Summary from {} to {}", Start, End),
);
}
Expand Down
12 changes: 5 additions & 7 deletions Source/Fn/Summary/Difference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
/// # Example
///
/// ```rust
/// let repo = git2::Repository::open("/path/to/repo")
/// .expect("Cannot open repository.");
/// let repo = git2::Repository::open("/path/to/repo").expect("Cannot open repository.");
/// let start_commit = "abc123";
/// let end_commit = "def456";
/// let options = crate::Struct::Summary::Difference::Struct {
/// Omit:vec!["(?i)\\.log$".to_string()],
/// };
/// let diff_summary = Fn(&repo, start_commit, end_commit, &options)
/// .expect("Cannot generate diff.");
/// let options =
/// crate::Struct::Summary::Difference::Struct { Omit:vec!["(?i)\\.log$".to_string()] };
/// let diff_summary =
/// Fn(&repo, start_commit, end_commit, &options).expect("Cannot generate diff.");
/// println!("{}", diff_summary);
/// ```
///
Expand Down
3 changes: 1 addition & 2 deletions Source/Fn/Summary/First.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
/// # Example
///
/// ```rust
/// let repo = git2::Repository::open("/path/to/repo")
/// .expect("Cannot open repository.");
/// let repo = git2::Repository::open("/path/to/repo").expect("Cannot open repository.");
/// let first_commit_oid = Fn(&repo).expect("Cannot retrieve first commit.");
/// println!("First commit OID: {}", first_commit_oid);
/// ```
Expand Down
14 changes: 6 additions & 8 deletions Source/Fn/Summary/Group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
/// let mut summary2 = DashMap::new();
/// summary2.insert(2, ("diff2".to_string(), "message2".to_string()));
///
/// let summaries = vec![
/// ("entry1".to_string(), summary1),
/// ("entry2".to_string(), summary2),
/// ];
/// let summaries = vec![("entry1".to_string(), summary1), ("entry2".to_string(), summary2)];
///
/// Fn(summaries);
/// ```
Expand Down Expand Up @@ -68,16 +65,17 @@ where
}
}

Output.into_iter().sorted_by(|(A, _), (B, _)| A.cmp(B)).for_each(
|(Message, Difference)| {
Output
.into_iter()
.sorted_by(|(A, _), (B, _)| A.cmp(B))
.for_each(|(Message, Difference)| {
println!("{}", Message);

Difference
.into_iter()
.sorted_by_key(|Difference| Reverse(Difference.len()))
.for_each(|Difference| println!("{}", Difference));
},
);
});
}

use std::{cmp::Reverse, collections::HashSet};
Expand Down
6 changes: 1 addition & 5 deletions Source/Fn/Summary/Insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
/// # Errors
///
/// This function does not return errors.
pub fn Fn(
Summary:&DashMap<u64, (String, String)>,
Difference:String,
Message:String,
) {
pub fn Fn(Summary:&DashMap<u64, (String, String)>, Difference:String, Message:String) {
Summary.insert(Hash::Fn(&Difference), (Difference, Message));
}

Expand Down
9 changes: 2 additions & 7 deletions Source/Struct/Binary/Command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ pub struct Struct {
pub Separator:Option::Separator,

/// A boxed asynchronous function that returns a pinned future.
pub Fn: Box<
dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
+ Send
+ 'static,
>,
pub Fn:Box<dyn Fn() -> Pin<Box<dyn Future<Output = ()> + Send + 'static>> + Send + 'static>,
}

impl Struct {
Expand All @@ -32,8 +28,7 @@ impl Struct {
Separator:std::path::MAIN_SEPARATOR,
Fn:Box::new(|| {
Box::pin(async move {
let Option =
Entry::Struct::Fn(&Option::Struct::Fn(Struct::Fn()));
let Option = Entry::Struct::Fn(&Option::Struct::Fn(Struct::Fn()));

match Option.Parallel {
true => {
Expand Down
15 changes: 3 additions & 12 deletions Source/Struct/Binary/Command/Option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,8 @@ impl Struct {
.map(|Exclude| Exclude.to_string())
.collect::<Vec<_>>(),
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(),
Pattern:Command().get_one::<String>("Pattern").expect("Cannot Pattern.").to_owned(),
Root:Command().get_one::<String>("Root").expect("Cannot Root.").to_owned(),
Separator,
Omit:Command()
.get_many::<String>("Omit")
Expand All @@ -65,10 +59,7 @@ impl Struct {
}
}

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

/// Type alias for a vector of strings representing command options.
pub type Command = Vec<String>;
Expand Down
3 changes: 1 addition & 2 deletions Source/Struct/Summary/Difference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
/// # Example
///
/// ```rust
/// let omit_patterns =
/// Struct { Omit:vec!["pattern1".to_string(), "pattern2".to_string()] };
/// let omit_patterns = Struct { Omit:vec!["pattern1".to_string(), "pattern2".to_string()] };
/// ```
pub struct Struct {
/// A vector of strings representing patterns to omit.
Expand Down
6 changes: 2 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ fn main() {

println!(
"cargo:rustc-env=CARGO_PKG_VERSION={}",
(toml::from_str::<Toml>(
&fs::read_to_string("Cargo.toml").expect("Cannot Cargo.toml.")
)
.expect("Cannot toml."))
(toml::from_str::<Toml>(&fs::read_to_string("Cargo.toml").expect("Cannot Cargo.toml."))
.expect("Cannot toml."))
.package
.version
);
Expand Down

0 comments on commit 3bab189

Please sign in to comment.