From a400fcff64a6f2216ac7a5b877fd860cd6d92a1c Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sat, 3 Aug 2024 10:52:55 +0300 Subject: [PATCH] --- Summary.md | 163 ++++++++--------------------------------------------- 1 file changed, 24 insertions(+), 139 deletions(-) diff --git a/Summary.md b/Summary.md index 214e904..935e1dd 100644 --- a/Summary.md +++ b/Summary.md @@ -2235,7 +2235,7 @@ index bdae5d9..85ac6fa 100644 +++ b/Cargo.toml + chrono = "0.4.38" diff --git a/Source/Fn/Summary.rs b/Source/Fn/Summary.rs -index b904dbd..f42cdc8 100644 +index b904dbd..d6728f0 100644 --- a/Source/Fn/Summary.rs +++ b/Source/Fn/Summary.rs - /// * `Entry` - A string slice representing the path to the git repository. @@ -2244,153 +2244,38 @@ index b904dbd..f42cdc8 100644 + /// * Option - A reference to a struct containing options for generating the diff summary. - /// Returns a `Result` containing a DashMap with the generated summaries if successful, or a boxed `dyn std::error::Error` if an error occurs. + /// Returns a Result containing a DashMap with the generated summaries if successful, or a boxed dyn std::error::Error if an error occurs. -- match Repository::open(Entry) { -- Ok(Repository) => { -+ let Repository = Arc::new(Repository::open(Entry)?); -+ - let mut Tag: Vec<_> = Name.iter().filter_map(|Tag| Tag).collect(); -+ let mut Date: Vec<(String, DateTime)> = Name -+ .par_iter() -+ .filter_map(|Tag| { -+ Tag.and_then(|Tag| { -+ Repository -+ .revparse_single(&Tag) -+ .ok() -+ .and_then(|Commit| Commit.peel_to_commit().ok()) -+ .map(|Commit| { -+ ( -+ Tag.to_string(), -+ DateTime::from_timestamp(Commit.time().seconds(), 0) -+ .unwrap() -+ .fixed_offset(), -+ ) ++ let mut Date: Vec<(String, DateTime)> = Name ++ .iter() ++ .filter_map(|Tag| { ++ Tag.and_then(|Tag| { ++ Repository ++ .revparse_single(&Tag) ++ .ok() ++ .and_then(|Commit| Commit.peel_to_commit().ok()) ++ .map(|Commit| { ++ ( ++ Tag.to_string(), ++ DateTime::from_timestamp(Commit.time().seconds(), 0) ++ .unwrap() ++ .fixed_offset(), ++ ) ++ }) + }) -+ }) -+ }) -+ .collect(); ++ }) ++ .collect(); + -+ Date.par_sort_by(|A, B| B.1.cmp(&A.1)); ++ Date.sort_by(|A, B| A.1.cmp(&B.1)); // Sort in descending order (newest first) - Tag.sort(); - Tag.dedup(); -+ let Tag: Vec = Date.into_iter().map(|(Tag, _)| Tag).collect(); -+ let (Approval, mut Receipt) = mpsc::unbounded_channel(); -+ let Approval = Arc::new(Mutex::new(Approval)); -+ -+ let mut Queue = FuturesUnordered::new(); -+ -- Insert::Fn( -- &Summary, -- crate::Fn::Summary::Difference::Fn(&Repository, &First, &Last, Option)?, -- format!("🗣️ Summary from first commit to last commit"), -- ) -+ let RepositoryClone = Repository.clone(); -+ let ApprovalClone = Approval.clone(); -+ let OptionClone = Option.clone(); -+ -+ Queue.push(tokio::spawn(async move { -+ let Summary = -+ crate::Fn::Summary::Difference::Fn(&RepositoryClone, &First, &Last, &OptionClone)?; -+ ApprovalClone -+ .lock() -+ .await -+ .send(("🗣️ Summary from first commit to last commit".to_string(), Summary))?; -+ Ok::<(), Box>(()) -+ })); ++ let Tag: Vec = Date.into_iter().map(|(Tag, _)| Tag).collect(); - let Start = Window[0]; - let End = Window[1]; -- -- Insert::Fn( -- &Summary, ++ let Start = &Window[0]; ++ let End = &Window[1]; - crate::Fn::Summary::Difference::Fn(&Repository, Start, End, Option)?, -- format!("🗣️ Summary from {} to {}", Start, End), -- ); -+ let Start = Window[0].clone(); -+ let End = Window[1].clone(); -+ let RepositoryClone = Repository.clone(); -+ let ApprovalClone = Approval.clone(); -+ let OptionClone = Option.clone(); -+ -+ Queue.push(tokio::spawn(async move { -+ let Summary = crate::Fn::Summary::Difference::Fn( -+ &RepositoryClone, -+ &Start, -+ &End, -+ &OptionClone, -+ )?; -+ ApprovalClone -+ .lock() -+ .await -+ .send((format!("🗣️ Summary from {} to {}", Start, End), Summary))?; -+ Ok::<(), Box>(()) -+ })); -- Insert::Fn( -- &Summary, -- crate::Fn::Summary::Difference::Fn(&Repository, &First, Latest, Option)?, -- format!("🗣️ Summary from first commit to {}", Latest), -- ); -- -- Insert::Fn( -- &Summary, -- crate::Fn::Summary::Difference::Fn(&Repository, Latest, &Last, Option)?, -- format!("🗣️ Summary from {} to last commit", Latest), -- ); -+ let Latest = Latest.clone(); -+ let RepositoryClone = Repository.clone(); -+ let ApprovalClone = Approval.clone(); -+ let OptionClone = Option.clone(); -+ -+ Queue.push(tokio::spawn(async move { -+ let Summary = crate::Fn::Summary::Difference::Fn( -+ &RepositoryClone, -+ &First, -+ &Latest, -+ &OptionClone, -+ )?; -+ ApprovalClone -+ .lock() -+ .await -+ .send((format!("🗣️ Summary from first commit to {}", Latest), Summary))?; -+ Ok::<(), Box>(()) -+ })); -+ -+ let RepositoryClone = Repository.clone(); -+ let ApprovalClone = Approval.clone(); -+ let OptionClone = Option.clone(); -+ -+ Queue.push(tokio::spawn(async move { -+ let Summary = crate::Fn::Summary::Difference::Fn( -+ &RepositoryClone, -+ &Latest, -+ &Last, -+ &OptionClone, -+ )?; -+ ApprovalClone -+ .lock() -+ .await -+ .send((format!("🗣️ Summary from {} to last commit", Latest), Summary))?; -+ Ok::<(), Box>(()) -+ })); -+ -+ drop(Approval); -+ -+ while let Some(Result) = Queue.next().await { -+ if let Err(E) = Result { -+ eprintln!("Task error: {}", E); -+ continue; -- Err(_Error) => { -- println!("Cannot Repository: {}", _Error); -- return Err(_Error.into()); -+ if let Err(E) = Result.unwrap() { -+ eprintln!("Inner task error: {}", E); -+ } -+ -+ while let Some((Message, Difference)) = Receipt.recv().await { -+ Insert::Fn(&Summary, Difference, Message); ++ crate::Fn::Summary::Difference::Fn(&Repository, &Start, &End, Option)?, + use chrono::{DateTime, FixedOffset}; -+ use futures::stream::{FuturesUnordered, StreamExt}; -+ use rayon::prelude::*; -+ use std::sync::Arc; -+ use tokio::sync::{mpsc, Mutex}; 🗣️ Summary from first commit to Summary/v0.1.1 in . diff --git a/.cargo/Config.toml b/.cargo/Config.toml