use std::path::Path;
pub(super) async fn collect_commit_log(dir: &Path, base: Option<&str>) -> Vec<String> {
let range = base
.map(|b| format!("{b}..HEAD"))
.unwrap_or_else(|| "HEAD~20..HEAD".to_string());
let output = tokio::process::Command::new("git")
.args(["log", "--oneline", "--no-decorate", &range])
.current_dir(dir)
.output()
.await;
match output {
Ok(o) if o.status.success() => String::from_utf8_lossy(&o.stdout)
.lines()
.filter(|l| !l.is_empty())
.map(String::from)
.collect(),
_ => vec![],
}
}
pub(super) fn format_commit_bullets(commits: &[String]) -> String {
commits
.iter()
.map(|c| format!("- {c}"))
.collect::<Vec<_>>()
.join("\n")
}