Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ categories = ["command-line-utilities"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.5.39", features = ["derive"] }
clap = { version = "4.5.40", features = ["derive"] }
git2 = { version = "0.20.2", features = [] }
regex = "1.11.1"
itertools = "0.14.0"
Expand Down
39 changes: 15 additions & 24 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ pub(crate) fn get_commits<'repo>(
if !before.is_empty() && !after.is_empty() {
let before_oid = repo.revparse_single(before)?.id();
let after_oid = repo.revparse_single(after)?.id();
revwalk.push_range(format!("{}..{}", before_oid, after_oid).as_str())?;
revwalk.push_range(format!("{before_oid}..{after_oid}").as_str())?;
} else if !after.is_empty() {
let after_oid = repo.revparse_single(after)?.id();
revwalk.push_range(format!("..{}", after_oid).as_str())?;
revwalk.push_range(format!("..{after_oid}").as_str())?;
} else if !before.is_empty() {
let before_oid = repo.revparse_single(before)?.id();
revwalk.push_range(format!("{}..", before_oid).as_str())?;
revwalk.push_range(format!("{before_oid}..").as_str())?;
}

let commits: Vec<Commit> = revwalk
Expand Down Expand Up @@ -69,10 +69,7 @@ fn get_commit_stats_for_commit<'repo>(
/// Display commit statistics.
pub(crate) fn show_commit_stats(stats: &[Result<DiffStats, Box<dyn Error>>], user_name: &String) {
if stats.is_empty() {
println!(
"Warning: The user \"{}\" did not contribute to this repository.",
user_name
);
println!("Warning: The user \"{user_name}\" did not contribute to this repository.");
return;
}

Expand All @@ -89,10 +86,10 @@ pub(crate) fn show_commit_stats(stats: &[Result<DiffStats, Box<dyn Error>>], use
}
});

println!("Commit statistics for user \"{}\":", user_name);
println!("Files changed: {}", total_files_changed);
println!("Insertions: {}", total_insertions);
println!("Deletions: {}", total_deletions);
println!("Commit statistics for user \"{user_name}\":");
println!("Files changed: {total_files_changed}");
println!("Insertions: {total_insertions}");
println!("Deletions: {total_deletions}");
}

/// Display a message about coding habits.
Expand Down Expand Up @@ -123,7 +120,7 @@ pub(crate) fn show_coding_habits(commits: &Vec<Commit>) {

println!("Commit message word occurrences:");
for (word, count) in word_counts.iter().sorted_by(|a, b| b.1.cmp(a.1)).take(10) {
println!("{}: {}", word, count);
println!("{word}: {count}");
}

let commit_date_times: Vec<DateTime<Utc>> = commit_times
Expand All @@ -142,10 +139,7 @@ pub(crate) fn show_coding_habits(commits: &Vec<Commit>) {

let (most_active_day, most_active_day_count) =
commit_activity.iter().max_by_key(|x| x.1).unwrap();
println!(
"Most active day: {} with {} commits",
most_active_day, most_active_day_count
);
println!("Most active day: {most_active_day} with {most_active_day_count} commits");

let mut commit_activity_hour: HashMap<String, usize> = HashMap::new();
for date_time in &commit_date_times {
Expand All @@ -157,10 +151,7 @@ pub(crate) fn show_coding_habits(commits: &Vec<Commit>) {
let (most_active_hour, most_active_hour_count) =
commit_activity_hour.iter().max_by_key(|x| x.1).unwrap();

println!(
"Most active hour: {} with {} commits",
most_active_hour, most_active_hour_count
);
println!("Most active hour: {most_active_hour} with {most_active_hour_count} commits");
}

pub(crate) fn show_top_committers(max: usize, commits: &Vec<Commit>) {
Expand All @@ -176,9 +167,9 @@ pub(crate) fn show_top_committers(max: usize, commits: &Vec<Commit>) {

top_committers.sort_by(|a, b| b.1.cmp(a.1));

println!("Top {} committers:", max);
println!("Top {max} committers:");
for (name, count) in top_committers.iter().take(max) {
println!("{}: {}", name, count);
println!("{name}: {count}");
}
}

Expand All @@ -200,11 +191,11 @@ mod tests {
assert!(repo.is_empty().is_ok(), "Failed to get repository");

let commits = get_commits(&repo, "", "");
println!("Commits: {:?}", commits);
println!("Commits: {commits:?}");
assert!(commits.is_ok(), "Failed to get commits");

let user = get_user_name();
println!("User: {}", user);
println!("User: {user}");
assert!(!user.is_empty(), "Failed to get user name");
}
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn check_directory_and_git(directory_path: &str) -> bool {
}
}

let git_path = format!("{}/.git", directory_path);
let git_path = format!("{directory_path}/.git");
if fs::metadata(git_path).is_err() {
println!("Error: Directory is not a Git repository.");
return false;
Expand Down