diff --git a/src/get_history.rs b/src/get_history.rs index 07898ff..814bb4d 100644 --- a/src/get_history.rs +++ b/src/get_history.rs @@ -1,10 +1,14 @@ use crate::exec::exec; -pub async fn get_history() -> Vec<(String, String)> { +pub async fn get_history(months: Option) -> Vec<(String, String)> { + let since_period = months + .map(|m| format!("{} months ago", m)) + .unwrap_or_else(|| "3 month ago".to_string()); + let git_log_command = [ "git", "log", - "--since=1 year ago", + &format!("--since={}", since_period), "--pretty=format:%H %ad", "--date=short", ]; diff --git a/src/main.rs b/src/main.rs index b306ae2..fc45edb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,7 +133,7 @@ async fn main() { todos_with_blame.sort_by(|a, b| a.blame.date.cmp(&b.blame.date)); - let mut history: Vec<(String, String)> = get_history().await; + let mut history: Vec<(String, String)> = get_history(Some(3)).await; let mut todo_count: usize = todos_with_blame.len(); let temp_file = File::create("todo_history_temp.json").expect("Failed to create temp file");