-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7be410b
commit d1975ad
Showing
587 changed files
with
429 additions
and
30,136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/// Defines and configures command-line arguments for the "Summary" command. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `ArgMatches` - The parsed command-line arguments. | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let matches = Fn(); | ||
/// let parallel = matches.get_flag("Parallel"); | ||
/// let root = matches.get_one::<String>("Root").unwrap(); | ||
/// ``` | ||
pub fn Fn() -> ArgMatches { | ||
Command::new("Summary") | ||
.version(env!("CARGO_PKG_VERSION")) | ||
.author("🖋️ Source — 👐🏻 Open — <Source/Open@PlayForm.Cloud>") | ||
.about("🗣️ Summary —") | ||
.arg( | ||
Arg::new("Parallel") | ||
.short('P') | ||
.long("Parallel") | ||
.action(SetTrue) | ||
.display_order(3) | ||
.value_name("PARALLEL") | ||
.required(false) | ||
.help("⏩ Parallel —"), | ||
) | ||
.arg( | ||
Arg::new("Root") | ||
.short('R') | ||
.long("Root") | ||
.display_order(4) | ||
.value_name("ROOT") | ||
.required(false) | ||
.help("📂 Root —") | ||
.default_value("."), | ||
) | ||
.arg( | ||
Arg::new("Exclude") | ||
.short('E') | ||
.long("Exclude") | ||
.display_order(5) | ||
.value_name("EXCLUDE") | ||
.required(false) | ||
.help("🚫 Exclude —") | ||
.default_value("node_modules"), | ||
) | ||
.arg( | ||
Arg::new("Pattern") | ||
.display_order(6) | ||
.value_name("PATTERN") | ||
.required(true) | ||
.help("🔍 Pattern —") | ||
.default_value(".git"), | ||
) | ||
.get_matches() | ||
} | ||
|
||
use clap::{Arg, ArgAction::SetTrue, ArgMatches, Command}; | ||
|
||
pub mod Entry; | ||
pub mod Parallel; | ||
pub mod Sequential; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/// Walks through a directory and filters files based on specified criteria. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `Option` - A struct containing the following fields: | ||
/// * `Exclude`: Vec<String> - List of patterns to exclude | ||
/// * `Pattern`: String - The pattern to match for inclusion | ||
/// * `Root`: String - The root directory to start the walk from | ||
/// * `Separator`: char - The path separator character | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Return` - A vector of vectors of strings, where each inner vector represents a file path | ||
/// split into its components. | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let option = Option { | ||
/// Exclude: vec!["node_modules".to_string()], | ||
/// Pattern: ".git".to_string(), | ||
/// Root: ".".to_string(), | ||
/// Separator: std::path::MAIN_SEPARATOR, | ||
/// }; | ||
/// let result = Fn(&option); | ||
/// ``` | ||
pub fn Fn(Option { Exclude, Pattern, Root, Separator, .. }: &Option) -> Return { | ||
WalkDir::new(Root) | ||
.follow_links(false) | ||
.into_iter() | ||
.filter_map(|Entry| { | ||
let Path = Entry.expect("Cannot Entry.").path().display().to_string(); | ||
|
||
// TODO: Separate this into Entry/Exclude.rs | ||
if !Exclude | ||
.clone() | ||
.into_iter() | ||
.filter(|Exclude| *Pattern != *Exclude) | ||
.any(|Exclude| Path.contains(&Exclude)) | ||
{ | ||
Some(Path.split(*Separator).map(|Entry| Entry.to_string()).collect()) | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect::<Vec<_>>() | ||
} | ||
|
||
use crate::Struct::Binary::Command::{Entry::Type as Return, Option::Struct as Option}; | ||
|
||
use walkdir::WalkDir; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/// Processes entries in parallel, filtering and executing commands based on specified criteria. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `Option` - A struct containing the following fields: | ||
/// * `Entry`: Vec<Vec<String>> - List of entries to process | ||
/// * `Separator`: char - The path separator character | ||
/// * `Pattern`: String - The pattern to match for inclusion | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let option = Option { | ||
/// Entry: vec![vec!["path".to_string(), "to".to_string(), "file.txt".to_string()]], | ||
/// Separator: '/', | ||
/// Pattern: "file.txt".to_string(), | ||
/// }; | ||
/// Fn(option).await; | ||
/// ``` | ||
pub async fn Fn(Option { Entry, Separator, Pattern, .. }: Option) { | ||
let Queue: Vec<_> = stream::iter( | ||
Entry | ||
.into_par_iter() | ||
.filter_map(|Entry| { | ||
Entry | ||
.last() | ||
.filter(|Last| *Last == &Pattern) | ||
.map(|_| Entry[0..Entry.len() - 1].join(&Separator.to_string())) | ||
}) | ||
.collect::<Vec<String>>(), | ||
) | ||
.map(|Entry| { | ||
tokio::spawn(async move { | ||
match crate::Fn::Summary::Fn(&Entry).await { | ||
Ok(summary) => Ok(summary), | ||
Err(e) => Err(format!("Error generating summary for {}: {}", Entry, e)), | ||
} | ||
}) | ||
}) | ||
.buffer_unordered(num_cpus::get()) | ||
.collect() | ||
.await; | ||
|
||
Queue.par_iter().for_each(|Output| match Output { | ||
Ok(Ok(Summary)) => println!("Summary: {:?}", Summary), | ||
Ok(Err(Error)) => eprintln!("Error: {}", Error), | ||
Err(Panic) => eprintln!("Panic: {}", Panic), | ||
}); | ||
} | ||
|
||
use crate::Struct::Binary::Command::Entry::Struct as Option; | ||
use futures::stream::{self, StreamExt}; | ||
use rayon::prelude::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/// Processes entries sequentially, filtering and executing commands based on specified criteria. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `Option` - A struct containing the following fields: | ||
/// * `Entry`: Vec<Vec<String>> - List of entries to process | ||
/// * `Pattern`: String - The pattern to match for inclusion | ||
/// * `Separator`: char - The path separator character | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let option = Option { | ||
/// Entry: vec![vec!["path".to_string(), "to".to_string(), "file.txt".to_string()]], | ||
/// Pattern: "file.txt".to_string(), | ||
/// Separator: '/', | ||
/// }; | ||
/// 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 | ||
}) | ||
} | ||
|
||
use crate::Struct::Binary::Command::Entry::Struct as Option; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/// Generates a summary based on the provided options. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `Option` - A struct containing the necessary information for generating the summary. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Return` - The generated summary. | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let option = Option { | ||
/// // Fields needed for summary generation | ||
/// }; | ||
/// let summary = Fn(&option); | ||
/// ``` | ||
pub async fn Fn(Entry: &str) -> Result<(), Box<dyn std::error::Error>> { | ||
let Repository = Repository::open(Entry)?; | ||
|
||
let Tag = Repository.tag_names(None)?; | ||
let mut Start = None; | ||
|
||
let Summary = "Summary"; | ||
fs::create_dir_all(Summary)?; | ||
|
||
for i in 0..Tag.len() { | ||
if let Some(Tag) = Tag.get(i) { | ||
if let Some(Start) = Start { | ||
let Difference = crate::Fn::Summary::Difference::Fn(&Repository, Start, Tag)?; | ||
|
||
File::create(&format!("{}/Difference_{}_{}.txt", Summary, Start, Tag))?.write_all( | ||
crate::Fn::Summary::Difference::Fn(&Repository, Start, Tag)?.as_bytes(), | ||
)?; | ||
|
||
File::create(&format!("{}/Release_{}_{}.txt", Summary, Start, Tag))? | ||
.write_all(crate::Fn::Summary::Release::Fn(&Difference).as_bytes())?; | ||
} | ||
|
||
Start = Some(Tag); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
use git2::Repository; | ||
use std::{ | ||
fs::{self, File}, | ||
io::Write, | ||
}; | ||
|
||
pub mod Difference; | ||
pub mod Release; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/// Calculates the difference between two summaries. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `Option` - A struct containing the necessary information for calculating the difference. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Return` - The calculated difference between the summaries. | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let option = Option { | ||
/// // Fields needed for difference calculation | ||
/// }; | ||
/// let difference = Fn(&option); | ||
/// ``` | ||
pub fn Fn(Repo: &git2::Repository, Start: &str, End: &str) -> Result<String, git2::Error> { | ||
let mut Difference = String::new(); | ||
|
||
Repo.diff_tree_to_tree( | ||
Some(&Repo.revparse_single(Start)?.peel_to_commit()?.tree()?), | ||
Some(&Repo.revparse_single(End)?.peel_to_commit()?.tree()?), | ||
Some(&mut git2::DiffOptions::new()), | ||
)? | ||
.print(git2::DiffFormat::Patch, |_, _, line| { | ||
Difference.push_str(std::str::from_utf8(line.content()).unwrap()); | ||
true | ||
})?; | ||
|
||
Ok(Difference) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/// Generates a release summary. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `Option` - A struct containing the necessary information for generating the release summary. | ||
/// | ||
/// # Returns | ||
/// | ||
/// * `Return` - The generated release summary. | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let option = Option { | ||
/// // Fields needed for release summary generation | ||
/// }; | ||
/// let release_summary = Fn(&option); | ||
/// ``` | ||
pub fn Fn(Difference: &str) -> String { | ||
let mut Release = String::new(); | ||
|
||
Release.push_str("Release Notes:\n"); | ||
|
||
for Difference in Difference.lines() { | ||
if Difference.starts_with("+") && !Difference.starts_with("+++") { | ||
Release.push_str(&format!("Added: {}\n", &Difference[1..])); | ||
} else if Difference.starts_with("-") && !Difference.starts_with("---") { | ||
Release.push_str(&format!("Removed: {}\n", &Difference[1..])); | ||
} | ||
} | ||
|
||
Release | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod Binary; | ||
pub mod Summary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
#![allow(non_snake_case)] | ||
|
||
mod Fn; | ||
mod Struct; | ||
|
||
/// The main entry point for the Summary application. | ||
/// | ||
/// This function initializes the command structure and executes the appropriate | ||
/// command based on the provided command-line arguments. | ||
#[allow(dead_code)] | ||
#[tokio::main] | ||
async fn main() { | ||
(Struct::Binary::Command::Struct::Fn().Fn)().await | ||
} | ||
|
||
pub mod Fn; | ||
pub mod Struct; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.