Added emails to the commit list and fixed the repo name not being found when using relative paths

master
Wynd 2025-10-05 01:27:27 +03:00
parent 66e7a76956
commit 8f4a8c18f9
2 changed files with 15 additions and 2 deletions

View File

@ -2,6 +2,7 @@
use std::{
cmp::Reverse,
fmt::Display,
path::{self, PathBuf},
sync::OnceLock,
};
@ -85,6 +86,12 @@ pub struct Author {
pub email: String,
}
impl Display for Author {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{} <{}>", self.name, self.email))
}
}
pub fn args() -> CliArgs {
let args = CliArgs::parse();
@ -122,11 +129,17 @@ pub fn get_commits(
(repos, branches)
}
None => {
let repos = match args.repos {
let mut repos = match args.repos {
Some(r) => r,
None => vec![PathBuf::from(".")],
};
// Turn any potential relative paths (such as `.`) into an absolute path
repos = repos
.iter_mut()
.filter_map(|p| std::fs::canonicalize(p).ok())
.collect_vec();
let branches = args.branches.unwrap_or_else(|| vec!["".to_string()]);
if repos.len() > 1 && repos.len() != branches.len() {

View File

@ -32,7 +32,7 @@ fn main() -> Result<()> {
commits.2.reverse();
for commit in commits.2 {
let repo = format!("{}{}", REPO_COLOR.to_ansi(), commit.repo);
let author = format!("{}{}", AUTHOR_COLOR.to_ansi(), commit.author.name);
let author = format!("{}{}", AUTHOR_COLOR.to_ansi(), commit.author);
let time = format!("{}{}", TIME_COLOR.to_ansi(), commit.time);
let message = commit.title;