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 91b2b40 commit d6ac8cd
Show file tree
Hide file tree
Showing 5 changed files with 689 additions and 5 deletions.
59 changes: 54 additions & 5 deletions Source/Fn/Summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
/// # Example
///
/// ```
/// let option = Option {
/// let Option = Option {
/// // Fields needed for summary generation
/// };
/// let summary = Fn(&option);
///
/// let summary = Fn(&Option);
///
/// ```
pub async fn Fn(
Entry: &str,
Expand All @@ -26,17 +28,63 @@ pub async fn Fn(

let Tag: Vec<_> = Name.iter().filter_map(|Tag| Tag).collect();

for (Index, &Current) in Tag.iter().enumerate() {
for (_, &Next) in Tag.iter().enumerate().skip(Index + 1) {
let Count = Tag.len();

let Head = Repository.head()?;

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

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

match Count {
0 => {
println!("Summary from {} to {}:", First, Last);

println!(
"{}",
crate::Fn::Summary::Difference::Fn(&Repository, &First, &Last, Option,)?
);
}
1 => {
let Latest = Tag.get(0).unwrap();

println!("Summary from {} to {}:", First, Latest);

println!(
"{}",
crate::Fn::Summary::Difference::Fn(&Repository, &First, Latest, Option,)?
);

println!("Summary from {} to {}:", Latest, Last);

println!(
"{}",
crate::Fn::Summary::Difference::Fn(&Repository, Current, Next, Option)?
crate::Fn::Summary::Difference::Fn(&Repository, Latest, &Last, Option,)?
);
}
_ => {
let Latest = Tag.get(Count - 1).unwrap();
let Previous = Tag.get(Count - 2).unwrap();

println!("Summary from {} to {}:", Previous, Latest);

println!(
"{}",
crate::Fn::Summary::Difference::Fn(&Repository, Previous, Latest, Option,)?
);

println!("Summary from {} to {}:", Previous, Last);

println!(
"{}",
crate::Fn::Summary::Difference::Fn(&Repository, Previous, &Last, Option,)?
);
}
}
}
Err(_Error) => {
println!("Failed to open repository: {}", _Error);

return Err(_Error.into());
}
}
Expand All @@ -47,3 +95,4 @@ pub async fn Fn(
use git2::Repository;

pub mod Difference;
pub mod First;
20 changes: 20 additions & 0 deletions Source/Fn/Summary/First.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// Function to iterate over the commits in a repository in reverse topological order.
///
/// # Arguments
/// * `Repository` - A reference to the repository to iterate over.
///
/// # Returns
/// * Result containing the next commit in the iteration or an error if no commits are found.
pub fn Fn(Repository: &Repository) -> Result<Oid, git2::Error> {
let mut Walk = Repository.revwalk()?;
Walk.push_head()?;
Walk.set_sorting(Sort::TOPOLOGICAL | Sort::REVERSE)?;

match Walk.next() {
Some(Ok(Identifier)) => Ok(Identifier),
Some(Err(_Error)) => Err(_Error),
None => Err(git2::Error::from_str("Cannot git2.")),
}
}

use git2::{Oid, Repository, Sort};
Loading

0 comments on commit d6ac8cd

Please sign in to comment.